2011-08-20 48 views
0

即時通訊使用谷歌地圖,當我嘗試添加標記時,我的代碼無法正常工作,任何人都可以在這裏看到我的代碼有什麼問題?我的Google地圖標記代碼中的錯誤在哪裏?

<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!" 
}); 

當我刪除了,劇本順利。

非常感謝您的幫助! :)

回答

3

請在標記的定義中注意myLatlng的拼寫(大寫)。它應該是myLatLng

+0

哇!這很有用,感謝幫助像我這樣的初學者。 :) – Emkey

+0

很好的接收。 – plexer