You can find out code here. I tried with global & local event both
event.preventDefault()
event.stopPropagation()
event.returnValue = false
event.cancelBubble = true;
above code working fine for mouse click events but for touch event map still receives click events.
答案 0 :(得分:1)
您可以为touchend
事件添加侦听器,以便停止此事件的传播:
google.maps.event.addDomListener(div, "click", function(e) {
console.log("over click");
e.preventDefault();
e.stopPropagation();
clickOverlay();
})
google.maps.event.addDomListener(div, "touchend", function(e) {
console.log("over touchend");
e.preventDefault();
e.stopPropagation();
clickOverlay();
})
这是您的小提琴更新:https://jsfiddle.net/beaver71/xx1ycd7L/