Problem with Google Map and unique openInfoWindowHtml
This is probably a simple issue but cant find how to fix it.
Im going through a list of lats and lons in a PHP array and plotting them on a Google map. I have the markers appearing correctly and have also loaded the data into each popup information window.
However when I click each marker the same popup window opens each time. Any ideas why
Here is the outputted JS code.
loadCityMap = function() {
var map = new GMap2(document.getElementById('citymap'));
map.setCenter(new GLatLng(51.9697, -8.5386), 9);
map.addControl(new GSmallMapControl());
map.addControl(new GMapTypeControl());
var point = new GLatLng(51.92553138896407,-8.15833568572998);
var marker = new GMarker(point, 1);
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml("1st window");
});
map.addOverlay(marker);
var point = new GLatLng(51.90500289069074,-8.412995338439941);
var marker = new GMarker(point, 2);
GEvent.addListener(marker, "click", function() {marker.openInfoWindowHtml("2nd Window");
});
map.addOverlay(marker);
}
Is is something to do with not closing listeners. :-(
Bookmarks