Skip to content Skip to sidebar Skip to footer

Adding Event Listener To Infowindow Google Maps V3

I tried to add some listeners for Info Window like: //works google.maps.event.addListener(markerInfoWindow, 'closeclick', function() { console.log('trigger close'); }); //does

Solution 1:

There is no documented "click" or "mouseover" event for an InfoWindow: The only documented events on an google.maps.InfoWindow (at present) are:

Events

closeclick Arguments: None

This event is fired when the close button was clicked.

content_changed Arguments: None

This event is fired when the content property changes.

domready Arguments: None

This event is fired when the containing the InfoWindow's content is attached to the DOM. You may wish to monitor this event if you are building out your info window content dynamically.

position_changed Arguments: None

This event is fired when the position property changes.

zindex_changed Arguments: None

This event is fired when the InfoWindow's zIndex changes.

You can add listeners for "click" and "mouseover" events on the content of the InfoWindow.

Solution 2:

As this link shows:

https://gist.github.com/thebouv/38f91f81675aad85f15d

you can add a 'domready' event listener to your info window. Once inside the callback you can attach event listeners to any of the info windows elements by id (using the standard "addEventListener"). The "onclick" method is much better but it didn't work well in my case because I was using react.

Post a Comment for "Adding Event Listener To Infowindow Google Maps V3"