将弹出窗口绑定到控件

时间:2017-04-09 21:07:36

标签: javascript leaflet

我有一个呈现按钮的LeafletJS控件。我希望按钮在单击时打开其位置的弹出窗口。到目前为止,我已经尝试在控件本身上调用.bindPopup方法,WebStorm似乎赞同这种方法,但浏览器告诉我这种方法并不存在。什么是完成这项任务的首选方式?

1 个答案:

答案 0 :(得分:2)

Leaflet controls don't implement the .bindPopup function.

Instead, you might find some luck looking at how the layers control works, it collapses/expands based on mouse events. You could potentially do something similar with your control, and show/hide your popup based on the click event and toggling a display: none css property.