In Google Maps v3, how do I close all currently open infowindows?
I can't just keep track of the last opened infowindow in a variable, as some have suggested, because in my setup each marker has unique text, and so I have to bind the infowindow to the marker at the point where it is created.
_.each(new_companies, function(c) {
var latLng = new google.maps.LatLng(c.com_d_coo_y_wgs84,
c.com_d_coo_x_wgs84);
var marker = new google.maps.Marker({'position': latLng});
marker.info = new google.maps.InfoWindow({
content: getTooltipText(c)
});
google.maps.event.addListener(marker, 'mouseover', function() {
marker.info.open(map, marker);
// How to close all currently open info windows?
});
google.maps.event.addListener(marker, 'click', function() {
marker.info.open(map, marker);
});
newco_markers.push(marker);
});
I guess I could loop through all the markers in newco_markers
and close the infowindow for each, but that feels inefficient.