jeffj
16 Oct 2010, 6:04 PM
I am trying to close existing overlays when a user clicks on a new marker on my map. I've tried every which way to tuesday.
var markers = {};
// These are all Google Maps APIs
var addMarker = function(entry) {
// if (marker[entry.id.$t]) {
// return;
// }
var pos = entry.content.kml$Placemark[0].kml$Point[0].kml$coordinates[0].$t.split(',');
var marker = new google.maps.Marker({
map: map.map,
title: 'whatever',
clickable: true,
position: new google.maps.LatLng(pos[1], pos[0]),
Icon: entry.gd$customProperty[4].$t
});
var overlay = new google.maps.InfoWindow({
content: entry.gd$customProperty[0].$t
});
google.maps.event.addListener(marker, "click", function() {
overlay.close();
overlay.open(map.map, marker);
});
// }
};
var markers = {};
// These are all Google Maps APIs
var addMarker = function(entry) {
// if (marker[entry.id.$t]) {
// return;
// }
var pos = entry.content.kml$Placemark[0].kml$Point[0].kml$coordinates[0].$t.split(',');
var marker = new google.maps.Marker({
map: map.map,
title: 'whatever',
clickable: true,
position: new google.maps.LatLng(pos[1], pos[0]),
Icon: entry.gd$customProperty[4].$t
});
var overlay = new google.maps.InfoWindow({
content: entry.gd$customProperty[0].$t
});
google.maps.event.addListener(marker, "click", function() {
overlay.close();
overlay.open(map.map, marker);
});
// }
};