我的Google Maps Marker代码中的错误在哪里?

时间:2011-08-20 10:19:40

标签: google-maps google-maps-api-3 google-maps-markers

我使用谷歌地图,当我尝试添加标记时,我的代码无效,任何人都可以在这里查看我的代码有什么问题?

<script type="text/javascript"> 

function initialize() {
    var myLatLng = new google.maps.LatLng(14.6084, 121.080258
);

    var myOptions = {
      zoom: 19,
      center: myLatLng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };

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

    var flightPlanCoordinates = [
        new google.maps.LatLng( 14.608037, 121.080236 ), 
        new google.maps.LatLng( 14.608154, 121.080277 ), 
        new google.maps.LatLng( 14.608245, 121.080298 ), 
        new google.maps.LatLng( 14.6084, 121.080258 ), 
        new google.maps.LatLng( 14.608543, 121.080148 ), 
        new google.maps.LatLng( 14.608699, 121.080113 ), 
    ];

    var flightPath = new google.maps.Polyline({
      path: flightPlanCoordinates,
      strokeColor: "#FF0000",
      strokeOpacity: 1.0,
      strokeWeight: 2
    });

    var marker = new google.maps.Marker({
        position: myLatlng, 
        map: map,
        title:"Hello World!"
    });   

   flightPath.setMap(map);
  }
</script> 

我刚刚添加的脚本是

var marker = new google.maps.Marker({
    position: myLatlng, 
    map: map,
    title:"Hello World!"
});  

当我删除它时,脚本运行良好。

非常感谢您的帮助! :)

1 个答案:

答案 0 :(得分:3)

请在标记的定义中查看myLatlng的拼写(大小写)。它应该是myLatLng