Google 地图 v3 标记的点击处理程序因 z 索引而中断?
我的 Google 地图 (v3) 呈现两种类型的标记:
区域标记(“您的家位于该区域”),这是一个半透明图形,其中的圆圈表示地图上的大致区域。
许多景点标记(海滩、餐馆、购物等)
每个景点标记都有一个可打开信息窗口的点击处理程序(“Bob's Bugs -镇上最好的炸虫子!”)。注册点击处理程序似乎还会创建悬停处理程序,将鼠标指针更改为手形,显示工具提示等,这很好。我没有为区域标记定义事件处理程序。
但是,对于区域标记范围内的景点标记,单击或悬停处理程序都不会触发。我猜想这是一个 z 索引问题,不知何故,大区域标记位于吸引力标记的顶部,正在拦截悬停/单击事件,并且不会传递它们。事实上,将鼠标悬停在区域标记上会出现其工具提示,这表明它肯定正在接收该事件。
我已经设置了各种标记的 z 索引 - 高 z 索引用于景点标记,低 z 索引用于区域标记。 DOM 的视觉渲染和检查表明 z-index 值实际上是按照我想要的设置的。
但不知何故,相交的吸引力标记没有收到它们的点击/悬停事件。其他景点标记可以正确响应其悬停/单击事件。事实上,对于仅与区域标记部分相交的吸引力标记,标记的外部部分响应悬停/单击事件。
根据这个答案,我尝试调用:
google.maps.event.clearInstanceListeners(this.areaMarker);
,希望可能有一些默认处理程序妨碍。没有爱。
有什么方法可以告诉区域标记让开吗?欢迎任何其他想法。
My Google Map (v3) renders two types of markers:
An area marker ("Your home is in this area"), a semi-transparent graphic with a circle denoting an approximate area on the map.
Many attraction markers (beaches, restaurants, shopping, etc.)
Each attraction marker has a click handler that opens an info window ("Bob's Bugs - the best fried bugs in town!"). Registering the click handler also seems to create hover handlers that change the mouse-pointer to a hand, display a tooltip, etc, which is fine. I am defining no event handlers for the area marker.
However, for the attraction markers that are within span of the area marker, neither the click nor hover handlers fire. I would guess that it is a z-index issue, that somehow the big area marker, is lying on top of the attraction markers, is intercepting the hover/click events, and is not passing them through. In fact, a hover on the area marker results in the its tooltip, suggesting to me that it is definitely picking up the event.
I have set the z-indexes of the various markers - high z-index for the attraction markers, low z-index for the area markers. The visual rendering and examination of the DOM suggests that the z-index values are actually being set as I want.
But somehow the intersecting attraction markers are not receiving their click/hover events. Other attraction markers respond correctly to their hover/click events. In fact, for an attraction marker that only partially intersects with the area marker, the external portion of the marker responds to the hover/click events.
Per this answer, I tried calling:
google.maps.event.clearInstanceListeners(this.areaMarker);
in the hopes that perhaps there were some default handlers getting in the way. No love.
Is there some way to tell the area marker to get the heck out of the way? Any other ideas welcome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案似乎是使用 ImageMapType 覆盖区域标记。这些覆盖不会拦截任何悬停/单击事件。
The solution seems to be to use an ImageMapType overlay for the area marker. These overlays will not intercept any of the hover/click events.