Object Creation In Loop Broken; Unrolled Works
I'm doing some testing and ran into this bizarre situation: The first case (assigning objects like InfoWindows in a loop) does not work as expected, while writing the assignments o
Solution 1:
Use closure:
for (var i = 0; i < 3; i++) {
(function(i){
iwArray[i] = new google.maps.InfoWindow({content: "w "});
google.maps.event.addListener(marker[i], 'mouseover', function(e) {
iwArray[i].open(map, this);
});
})(i);
}
Post a Comment for "Object Creation In Loop Broken; Unrolled Works"