移动可拖动标记时,强制传单弹出窗口保持打开状态 [英] Force Leaflet popup to stay open when a draggable marker is moved
问题描述
我正在开发一个旨在对旧照片进行地理标记的众包应用程序.我显示一个图像缩略图网格,当我单击它时,它会在地图上放置一个可拖动标记,并打开包含图像和相关详细信息的弹出窗口.这样做是:
I am working on a crowdsourcing app aimed at geotagging old pictures. I display a grid of image thumbnails and when I click on one it places a draggable marker on the map and opens the popup containing the image and associated details. This is done with:
L.marker([newlat, newlng], {
icon: movableIcon,
draggable:true
}).addTo(map).bindPopup(popupContent).openPopup();
这可行,但是只要用户拖动标记,弹出窗口就会关闭,将他们尝试设置的东西隐藏在正确的位置.
This works, but as soon as a user drags the marker the popup closes, hiding the very thing that they are trying to set at the correct location.
有人知道如何使弹出窗口保持打开状态吗?
Does anyone know how to keep the popup open?
谢谢
推荐答案
最后,我仅使用
marker.bindPopup("popup content").addTo(map).openPopup();
marker.on('dragend', function(e) {
marker.openPopup();
});
在拖动时弹出窗口消失,但是在用户停止时再次出现.在我的应用程序中,这实际上是相当不错的用户体验.
The popup disappears whilst dragging, but then reappears when the user stops. Which is actually quite a nice user experience in my application.
这篇关于移动可拖动标记时,强制传单弹出窗口保持打开状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!