Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
143
rated 0 times [  149] [ 6]  / answers: 1 / hits: 74552  / 13 Years ago, thu, july 21, 2011, 12:00:00

I like to keep track of any and all infowindows that are open on my Google Maps interface (I store their names in an array), but I can't figure out how to remove them from my array when they are closed via the x in the upper right hand corner of each one.



Is there some sort of callback I can listen for? Or maybe I can do something like
addListener(close, infowindow1, etc ?


More From » jquery

 Answers
34

The only consistent solution I've found here is to retain a pointer to the infoWindow and check its .getMap() method whenever you need to validate whether it has been closed.



The reason for this is that clicking another element can cause the infoWindow to be dismissed for other reasons... without the closeclick event firing.



var infoWindow = new google.maps.InfoWindow({ content: 'Something to put here.' });
infoWindow.open(map, infoWindow);

setInterval(function ()
{
console.log(infoWindow is bound to map: +(infoWindow.getMap() ? true : false));

}, 1000);


... If you literally only care if the infoWindow was closed using the X button, then monitoring closeclick is fine. However, there are other reasons it may be or have been closed.


[#91078] Wednesday, July 20, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
aubriea

Total Points: 641
Total Questions: 118
Total Answers: 101

Location: French Southern and Antarctic Lands
Member since Fri, Jan 6, 2023
1 Year ago
;