Reputation: 828
I have created some editBox and buttons in a Google overlayView on top of Google map in JavaScript. Whenever I am clicking on any button, editBox or anywhere on overlayView, Google map is also accepting those mouse events. How can I restrict mouse events so they can't propagate through overlayView?
google.maps.event.addDomListener(gotoBtn, 'click', function(e) {
///DO SOMETHING
e.stopPropagation();
});
For buttons, I am using the following method, but I don't want to put the same everywhere for all. Is there any other logical way?
Upvotes: 2
Views: 949
Reputation: 828
I added div in overlayView and stopping mouse propagation there.
var panes = this.getPanes();
panes.overlayImage.appendChild(div);
/// Code for stoping event propagation to m_map
div.onclick = function(event) {
event.stopPropagation();
}
google.maps.event.addDomListener(div, 'mousedown', function (event) {
event.cancelBubble = true;
if(event.stopPropogation)
event.stopPropagation();
});
Upvotes: 1