2012-03-04 43 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 
    }); 

} 

工作现在