I'm making a mobile web app.
Part of the app drops several markers, which can be clicked to open info windows. It irritates me that these do not go away if you continue using the map without acknowledging them, as in the iOS maps app.
Is there a way to set it so that if the user clicks the underlying map, all open info windows are closed?
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.
You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!
Disable auto-pan on open. By default, the info window will pan the map so that it is fully visible when it opens. Sets the open state for the InfoWindow. You can also call the open() and close() methods.
Try this:
google.maps.event.addListener(map, "click", function(event) { infowindow.close(); });
It is quite simple an should work as well.
add listener to map's click event and close infoboxes in its handler
google.maps.event.addListener(map, "click", function(event) { for (var i = 0; i < ibArray.length; i++ ) { //I assume you have your infoboxes in some array ibArray[i].close(); } });
I do that on typical websites, but don't see any reason it wouldn't work on mobile
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