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.