1
我想要一個接一個地放棄我的標記,而不是同時放下所有的標記。我的drop function()
似乎沒有在這裏工作。我不知道什麼是錯的。請看看我的代碼。谷歌地圖標記DROP
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(63.417622, 10.404316);
var mapOptions = {
zoom: 13,
center: myLatlng
};
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
var marker;
var locations = [];
locations.push ({name: "1", p: new google.maps.LatLng(63.417622, 10.404316)});
locations.push ({name: "2", p: new google.maps.LatLng(63.409868, 10.446512)});
locations.push ({name: "3", p: new google.maps.LatLng(63.429070, 10.390894)});
locations.push ({name: "4", p: new google.maps.LatLng(63.437208,10.452692)});
function addMarker(){
for (var i = 0; i < locations.length; i++){
marker = new google.maps.Marker({position: locations[i].p, map: map, title: locations[i].name, icon: 'cabin_icon.png', animation: google.maps.Animation.DROP});
}
} //This put my markers on the map all at once.
//Function to drop them at one after another after a few milliseconds.
function drop(){
for (var j = 0; j < locations.length; j++) {
setTimeout(function(){
addMarker();
}, j * 200);
};
}; //But this function is not working. Markers are not even showing up after I have created this function.
}
google.maps.event.addDomListener(window, 'load', initialize); </script>
我試圖以許多不同的方式編輯代碼,但無法正確地編輯代碼。我也試過Google tutorial on this,也沒有代碼的運氣。所以我需要你的幫助。