I have a click
event binded on an element which contains a Google Map. When the user close an InfoWindow on the map clicking on the cross, the click event is fired and propagate all over the DOM. I want to stop this event propagation, so the infoWindow closes but the click event is no raised on my container.
Google Maps API provide a closeclick
event which is raised when the InfoWindow is closed, however this event can't be accessed (it is not present as a parameter):
google.maps.event.addListener(infowindow, "closeclick", function() {
// The API function doesn't have the e parameter, I can't access closeclick
});
As my container is binded to click
anyway, I'm not even sure closeclick.stopPropagation()
would have worked. So I'm looking for a way to access the click event thrown by Google Map when the user clicks the cross. Of course, the html of google maps is so messed up I can't access the cross DOM element to add an eventListener to it (it's only divs everywhere, without any classes).
Any suggestions?
Edit: As a workaround, I fixed this problem by modifying my own code and testing where the event comes from when it is catched by my container:
container.addEventListener('click', function(ev) {
if (ev.target.src == 'https://maps.gstatic.com/mapfiles/api-3/images/mapcnt6.png') {
return false;
}
// the code I want to execute only when the click event doesn't come from the InfoWindow
});