gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-04 13:34:28 26 4
gpt4 key购买 nike

我已经按照谷歌文档的说明对我的覆盖对象进行了子类化,下面列出了我的 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com