向两个完全重叠的层(带有子节点)发送点击事件
好的,我的页面(html、javascript、css)有两层,完全覆盖浏览器窗口。前面的导航包含应该可点击的导航。后面的地图包含一张带有标记的地图,这些标记也应该是可点击的。导航(前面的导航)有时会占据整个窗口的高度和宽度,因此限制其大小实际上并不是一种选择。
现在的问题是如何将单击事件传递到后面图层,以便地图标记可以接收其单击事件。 backlayer.dispatchEvent(e) 将 backlayer 作为事件目标,但是 backlayer 内的任何标记都可能是目标,所以我想知道是否有更简单的方法,然后检查每个地图标记元素的边界框并调用dispatchEvent在直接匹配的地图标记上?
谢谢!
Ok, I have page (html, javascript, css) with two layers that completely cover the browser window. The one in front contains a navigation that should clickable. The one in the back contains a map with markers that should also be clickable. The navigation (the one in the front) at times can occupy the complete window height and width so limiting it's size is not really an option.
Now the problem is how to get the click events to the back layer so the map markers can receive their click event. backlayer.dispatchEvent(e) takes backlayer as the event target, but any of my markers inside the backlayer could be the target, so I was wondering if there is a simpler way then check the bounding-box of every map marker element and call dispatchEvent on the map marker that matches directly?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用 jQuery 或类似的库来模拟点击上层时点击底层。
You can try using jQuery or a similar library to simulate a click on the bottom layer when clicking the upper one.