我想在谷歌地圖添加標記,我有這樣的代碼問題添加標記,谷歌地圖在瀏覽器
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?key=myKey&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(56.33481154165235, 11.107177734375),
zoom: 7,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
setMarker();
}
// Function for adding a marker to the page.
function addMarker(location) {
marker = new google.maps.Marker({
position: location,
map: map
});
}
// Testing the addMarker function
function setMarker() {
CentralPark = new google.maps.LatLng(55.671389288295465, 12.5601196289062);
addMarker(CentralPark);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
這顯示了地圖,但沒有標記。
在此之前,感謝您的幫助!
謝謝你這段代碼,我會嘗試一下,看看它是否工作。 – ACetin 2013-03-19 12:58:08
爲什麼downvote,無論它是誰? – duncan 2013-04-24 12:27:11