0

我完全不知道为什么。这是我第一次尝试使用 Maps API v3 执行此操作。地图显示正确,但看不到任何标记。这是代码:

<script>
window.onload = function(evt) {
 if(document.readyState === 'complete') {
   var latlng = new google.maps.LatLng(50.833, 4.333);
   var styles = [
     {
       stylers: [
         { hue: '#ffdd00' }
       ]
     }
   ];
   var myOptions = {
     zoom: 16,
     scrollwheel: false,
     mapTypeControl: false,
     disableDoubleClickZoom: true,
     draggable: false,
     navigationControl: false,
     streetViewControl: false,
     center: latlng,
     mapTypeId: google.maps.MapTypeId.ROADMAP,
     styles: styles
   };
   var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);    
   var image = '/img/marker.png';
   map.addMarker({
     lat: 50.833,
     lng: 4.333,
     title: 'Here it is',
     icon: image,
     });        
   }
}
</script>

有任何想法吗?

4

1 回答 1

1

没有addMarker()方法。

尝试new google.maps.Marker()

var marker = new google.maps.Marker({
     position: latlng, 
     map: map, 
     title: 'Here it is',
     icon: image,
     }); 
于 2013-02-06T11:44:29.887 回答