简体   繁体   中英

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.

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?

Add a click listener to your DOM (overlay) element:

overlay_element.addEventListener('click', function(){
  // call your search function
});

在重新阅读Openlayers示例时,有一个选项可以停止事件传播,因此我将其设置为false,它允许我通过覆盖标记图像查询地图。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM