Может кто-нибудь сказать мне, почему это не работает?
jeMarkers - это массив маркеров Google Maps.
function toggleBounce() {
var bcounter = 0;
$(jeMarkers).each(function () {
setTimeout(function () {
if (this.getAnimation() != null) {
this.setAnimation(null);
} else {
this.setAnimation(google.maps.Animation.BOUNCE);
}
}, bcounter * 100);
bcounter++;
});
}
Если я делаю то же самое без функции setTimeout, она работает, ноочевидно делает все маркеры сразу:
function toggleBounce() {
$.each(jeMarkers, function () {
if (this.getAnimation() != null) {
this.setAnimation(null);
} else {
this.setAnimation(google.maps.Animation.BOUNCE);
}
});