On my site, I'm using Google Maps API v3 to place house markers on the map.
The InfoWindows stay open unless you explicitly click the close icon. Meaning, you can have 2+ InfoWindows open at a time if you hover over the map marker.
Question: How do I make it so that only the current active InfoWindow is open and all other InfoWindows are closed? Meaning, no more than 1 InfoWindow will be open at a time?
An InfoWindow displays content (usually text or images) in a popup window above the map, at a given location. The info window has a content area and a tapered stem. The tip of the stem is attached to a specified location on the map. Info windows appear as a Dialog to screen readers.
You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!
There is a close() function for InfoWindows. Just keep track of the last opened window, and call the close function on it when a new window is created.
alternative solution for this with using many infowindows: save prev opened infowindow in a variable and then close it when new window opened
var prev_infowindow =false; ... base.attachInfo = function(marker, i){ var infowindow = new google.maps.InfoWindow({ content: 'yourmarkerinfocontent' }); google.maps.event.addListener(marker, 'click', function(){ if( prev_infowindow ) { prev_infowindow.close(); } prev_infowindow = infowindow; infowindow.open(base.map, marker); }); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With