I\'ve been having problems with the infoWindows and Google Maps API v3. Initially, I\'ve ran into the problem that everyone else has of closing infoWindows when opening a new on
UPDATED
You are calling
infowindow.open(map,marker);
inside an jQuery.each iteration, thus, i think it will be calling the last item in the iteration. Modify your code so you get this inside the jQuery.each iteration.
var curItem = 1;
google.maps.event.addListener(aMarker, "click", function(idx, theContent) {
return function() {
alert(idx); //Should print 1 marker1, 2 for marker 2, to show it's ok.
//Your stuff...
if (infowindow) {
infowindow.close(map,marker);
}
infowindow.setContent(theContent);
infowindow.open(map,marker);
}
} (curItem++, contentString)
);
When you see "return function()" I'm using a javascript closure. I've just used this closure for other stuff. I've got rid of other previous variations in my previous answer.