0
我每秒鐘都有一次加載一個標記。有50個,需要一段時間來加載所有這些。因此,爲了表明它們仍在加載,我已將其動畫設置爲反彈。但一旦他們全部加載,我想停止彈跳動畫。我怎麼做??在所有標記加載後停止彈跳標記
var geocoder;
var map;
var addresses = new Array();
var infowindow;
var theInterval;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(42.095287, -79.3185139);
var myOptions = {
maxZoom: 14,
zoom: 9,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
infowindow = new google.maps.InfoWindow({});
}
$(document).ready(function() {
getAddresses();
theInterval = setInterval("codeAddress()", 1000);
});
function getAddresses() {
$('.LocationAddress').each(function() {
addresses.push($(this).text());
});
}
function codeAddress() {
if (addresses.length == 0) {
clearInterval(theInterval);
}
var addy = addresses.pop();
geocoder.geocode({
'address': addy
}, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
position: results[0].geometry.location,
map: map,
title: addy,
animation: google.maps.Animation.BOUNCE,
});
//Adding a click event to the marker
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent('<div id=\"infowindow\" style=" height:100px;>' + '<div id=\"LeftInfo\">' + "Hello World!" + '</div>' + '</div>');
infowindow.open(map, this);
});
}
}); //Geocoder END
}