[英]Clickable map overlay in OL3?
I have a map overlay which displays the image of a house through its element parameter when the user navigates to the property they have searched for. 我有一个地图叠加层,当用户导航到他们要搜索的属性时,该叠加层通过其element参数显示房屋的图像。
The problem is I have a search tool which allows the user to search the map based on a map click; 问题是我有一个搜索工具,该工具可让用户根据点击地图来搜索地图; when the user finds their property they click on the house image but it does not activate the search because the image blocks the map click option.
当用户找到他们的财产时,他们单击房屋图像,但由于图像会阻止地图单击选项,因此不会激活搜索。
Is there a way I can allow the user to click on the map through the image? 有没有一种方法可以允许用户通过图像单击地图? Would this be done with CSS or are there parameters / properties for the overlay element that I can set which will allow this?
将使用CSS完成此操作还是我可以设置overlay元素的参数/属性来设置?
Add a click listener to your DOM (overlay) element: 将点击侦听器添加到您的DOM(覆盖)元素中:
overlay_element.addEventListener('click', function(){
// call your search function
});
在重新阅读Openlayers示例时,有一个选项可以停止事件传播,因此我将其设置为false,它允许我通过覆盖标记图像查询地图。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.