Closing any open info windows in google maps api v3

Posted by hhj on Stack Overflow See other posts from Stack Overflow or by hhj
Published on 2010-06-03T14:13:28Z Indexed on 2010/06/03 14:34 UTC
Read the original article Hit count: 229

As the title states, on a given event (for me this happens to be upon opening a new google.maps.InfoWindow I want to be able to close any other currently open info windows. Right now, I can open many at a time..but I want only 1 open at a time.

I am creating the info windows dynamically (i.e. I don't know ahead of time how many will be generated), so in the click event of the current info window (which is where I want all the other open ones closed) I don't have a reference to any of the other open info windows on which to call close(). I am wondering how I can achieve this. I am not an experienced JavaScript programmer so I don't know if I need to use reflection or something similar here.

Would the best way be just to save all the references in some sort of collection, then loop through the list closing them all?

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about google-maps