I had a problem in placing an openInfoWindowHtml in my array of markers. Without the addListener inside the for loop, the map.addOverlay(markerArray[i]) works fine. What is wrong in my code? Thanks!
function addMarkers(){
var tempMarker;
var blueIcon = new GIcon(G_DEFAULT_ICON);
blueIcon.image = "http://www...com/.../.png";
// Set up our GMarkerOptions object
markerOptions = { icon:blueIcon };
for(ctr=0;ctr<default_address.length;ctr++){
tempLatLng = new GLatLng(default_address[ctr][0], default_address[ctr][1]);
tempMarker = new GMarker(tempLatLng,markerOptions);
GEvent.addListener(tempMarker, "click", function()
{tempMarker.openInfoWindowHtml("HI")});
markerArray.push(tempMarker);
}
displayMarkers();
}
function displayMarkers(){
map.clearOverlays();
var i;
for (i = 0; i < markerArray.length; i++) {
map.addOverlay(markerArray[i]);
}
}