google-maps - 如何在 IE 和 Firefox 中使用 Google map v3 将点击事件绑定(bind)到自定义叠加层

标签 google-maps overlay clickable

我已经按照谷歌文档的说明对我的覆盖对象进行了子类化,下面列出了我的 onAdd() 函数:

MyOverlay.onAdd() {
    var div_parent = document.createElement("DIV");
    var div_child = document.createElement("DIV");
    div_child.innerHTML = "Click Me";
    div_parent.appendChild( div_child );
    this.getPanes().overlayLayer.appendChild(div_parent);
    var this = that;
    google.maps.event.addDomListener( div_parent, 'click', function(){
        google.maps.event.trigger(that, 'click'); // from [http://stackoverflow.com/questions/3361823/make-custom-overlay-clickable-google-maps-api-v3]
        alert("Clicked");
    } );

}

我的代码只能在 IE 中正常运行,但在 Firefox 和 Chrome 中,将不再触发点击事件。

那么如何解决问题呢?

最佳答案

而不是使用overlayLayer mapPanes,您应该使用overlayMouseTarget。

引用:http://code.google.com/apis/maps/documentation/javascript/overlays.html#CustomOverlays

关于google-maps - 如何在 IE 和 Firefox 中使用 Google map v3 将点击事件绑定(bind)到自定义叠加层,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6798971/

相关文章:

Android - 在 ImageView 上创建可点击区域

android - 在谷歌地图中沿着道路画一条线

ios - Swift Google Map Marker Tap 事件对我不起作用

iphone - 移动 map 叠加层

android - 如何向 ClusterItem 添加标题、摘要和图标?

android 地理定位通知

ios - 我想将 GoogleMaps 添加到我的 iOS 项目中,但我不想使用 CocoaPods。有什么办法可以实现吗?

android - Recyclerview 叠加工具栏

html - iOS7:在固定覆盖层中滚动会导致主体滚动