2012-03-04 14 views
1

我使用谷歌地圖上添加標記http://code.google.com/p/jquery-ui-map/如何使用jQuery UI的地圖

HTML:

<div id="map_canvas" style="width: 100%; height:400px;" latitude="123456" longitude="123456">Loading Map</div> 

jQuery的

$(function() { 
     $('#map_canvas').gmap({ 
      'center': new google.maps.LatLng($('#map_canvas').attr('latitude'),$('#map_canvas').attr('longitude')), 
      'zoom': 13 
     }); 
    }); 

它工作正常但我無法添加標記。我在文檔中嘗試了很多選項,但無法放置標記。

任何想法?

感謝

回答

2

,這是我發現:

http://code.google.com/apis/maps/documentation/javascript/overlays.html#MarkerAnimations

// Google Maps 
function GoogleMaps() { 

    var latitude = $("#map_canvas").attr('latitude'); 
    var longitude = $("#map_canvas").attr('longitude'); 

    var location = new google.maps.LatLng(latitude, longitude); 
    var marker; 
    var map; 

    var mapOptions = { 
      zoom: 13, 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      center: location 
    }; 

    map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions); 

    marker = new google.maps.Marker({ 
     map:map, 
     animation: google.maps.Animation.DROP, 
     position: location 
    }); 

} 

工作現在