Please, I need a help.
I want to check if my infowindow is opened.
For example:
if (infowindow.isOpened) { doSomething() }
or
if (infowindow.close) { doAnotherthing(); }
I dont have any idea, how to do this
Calling InfoWindow. getOpenedState() returns a boolean which reflects the state (opened/closed) of the infowindow.
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.
When you create an info window, it is not displayed automatically on the map. To make the info window visible, you must call the open() method on the InfoWindow , passing an InfoWindowOpenOptions object literal specifying the following options: map specifies the map or Street View panorama on which to open.
You can modify the whole InfoWindow using jquery alone... var popup = new google. maps. InfoWindow({ content:'<p id="hook">Hello World!
This is an undocumented feature, and is therefore subject to change without notice, however the infoWindow.close()
method sets the map on the object to null
(this is why infoWindow.open(map, [anchor])
requires that you pass in a Map
), so you can check this property to tell if it is currently being displayed:
function isInfoWindowOpen(infoWindow){ var map = infoWindow.getMap(); return (map !== null && typeof map !== "undefined"); } if (isInfoWindowOpen(infoWindow)){ // do something if it is open } else { // do something if it is closed }
Update: Another potentially useful way to write this is to add an isOpen()
method to the InfoWindow
prototype
.
google.maps.InfoWindow.prototype.isOpen = function(){ var map = this.getMap(); return (map !== null && typeof map !== "undefined"); }
Until google doesn't give us any better way of doing this, you can add a property to the infoWindow objects. Something like:
google.maps.InfoWindow.prototype.opened = false; infoWindow = new google.maps.InfoWindow({content: '<h1> Olá mundo </h1>'}); if(infoWindow.opened){ // do something infoWindow.opened = false; } else{ // do something else infoWindow.opened = true; }
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