Stop propagation of click event?

2,041 views
Skip to first unread message

Grégoire Colbert

unread,
Apr 15, 2011, 4:49:24 AM4/15/11
to Google Maps JavaScript API v3
Hi!

I have a google.maps.InfoWindow that contains a DOM element associated
with the "onclick" event.

My problem is that if the infowindow is opened on a given marker which
is located in such a place that there is another marker just "below"
the infowindow's button, then when I click the infowindow's button,
the underneath marker receives the click event too.

Is there a way to stop the propagation of the event?

Thanks!
Grégoire

Pil

unread,
Apr 15, 2011, 5:20:25 AM4/15/11
to Google Maps JavaScript API v3
This sounds like a bug (maybe even a regression bug) because when you
click on a link inside the infowindow no click event underneath the
infowindow should be triggered.

Can you provide a link to the map that exhibits the problem?

Martin™

unread,
Apr 16, 2011, 3:15:53 AM4/16/11
to Google Maps JavaScript API v3
Try something like this:

function stopPropagation(myEvent){
if(!myEvent){
myEvent=window.event;
}
myEvent.cancelBubble=true;
if(myEvent.stopPropagation){
myEvent.stopPropagation();
}
}

google.maps.event.addDomListener(myHtmlElement, 'click',
function(myEvent){
stopPropagation(myEvent);
});

Martin.

en4ce

unread,
Apr 16, 2011, 12:59:34 PM4/16/11
to Google Maps JavaScript API v3
you can use other events if you dont find a work around like,
onmousedown / up
Reply all
Reply to author
Forward
0 new messages