适用于Google Maps v3的RichMarker - 点击标记 [英] RichMarker for Google Maps v3 - Click falls through marker

查看:167
本文介绍了适用于Google Maps v3的RichMarker - 点击标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 https:// googlemaps上使用了RichMarker for Google Maps v3 .github.io / js-rich-marker / reference.html

我已经成功注册了以下代码的标记: p>

I have successfully been able to register clicking on the marker with this code:

google.maps.event.addListener(this.richMarker, 'click', function(event) {
    console.log("click made on marker");
});

然而,点击也会落在标记上,所以它会记录下任何落在它后面的点击。即地图,如果它有一个处理程序:

However the click also falls through the marker, so it registers a click on whatever falls behind it. ie the map, if it has a handler:

google.maps.event.addListener(map, 'click', function(event) {
    console.log("click made on map");
});

或者是可点击的多边形。

Or a polygon if it is clickable.

如何通过点击RichMarker来防止此次秋天?

How can I prevent this fall through click with RichMarker?

谢谢

Thanks

推荐答案

找到这个零件:

google.maps.event.addDomListener(this.markerContent_, 'click',   function(e) {
  google.maps.event.trigger(that, 'click');
});

并将其更改为

and change it to

google.maps.event.addDomListener(this.markerContent_, 'click', function(e) {
  e.stopPropagation();
  google.maps.event.trigger(that, 'click');
});

这篇关于适用于Google Maps v3的RichMarker - 点击标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆