Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GMaps V3 InfoWindow - disable the close "x" button

From what I see, in v2 of GMaps API there was a property "buttons" of the InfoWindow object that one could define in a way that given InfoWindow has no close button:

marker.openInfoWindowHtml("No Close Button",{buttons:{close:{show:4}}}); 

The above however does not apply for v3. Does anybody know a way to do it? I read about an utility that replaces InfoWindow called InfoBox but it has not been developed for the past 2 years. I'm currently using the latest 3.13 version of Gmaps v3 API.

A workaround with jQuery is acceptable, if there is no better solution.

like image 346
ddinchev Avatar asked Sep 21 '13 13:09

ddinchev


People also ask

How do I get rid of InfoWindow in Google Maps?

After constructing an InfoWindow, you must call open to display it on the map. The user can click the close button on the InfoWindow to remove it from the map, or the developer can call close() for the same effect.

How do I know if InfoWindow is open?

Calling InfoWindow. getOpenedState() returns a boolean which reflects the state (opened/closed) of the infowindow.

What is InfoWindow in Google map?

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.

How do I change the width of InfoWindow on Google Maps?

maps. InfoWindow({ content: some_text, maxWidth: 200 }); The documentation notes that the "value is only considered if it is set before a call to open. To change the maximum width when changing content, call close, setOptions, and then open."


1 Answers

You can also do it through the css.

.gm-style-iw + div {display: none;} 

edit january 2019
as @antmeehan said in the comment,

Google have changed the HTML, and the close button is now a button element rather than a div

So the css code to hide the "x" button is now:

.gm-style-iw + button {display: none;} 
like image 195
Louis Moore Avatar answered Sep 27 '22 17:09

Louis Moore