[英]Leaflet - How to match marker and polyline on drag and drop #2 (delete the last marker and polyline with button click)
[英]How to Drag a Marker if you click it? Leaflet
大家好,我正在開發一個具有地圖功能的網站。 我的目標是單擊標記將其拖動。
這是我的代碼
else if (select1.value === "Arson"){
var note = document.getElementById('note');
var datepick = document.getElementById('demo1');
var timepick = document.getElementById('timepick');
layerpoly.on('click', function(e){
var markerA = new L.Marker(e.latlng,{icon: Icon1});
markerA.bindPopup("</a><br><strong>ARSON</strong></br><strong>Date:</strong>"+datepick.value+"</br><strong>Time:</strong>"+timepick.value+"</br><strong>Address:</strong>"+note.value+"<strong><br><strong>Suspect Sketch</strong><br><a href=legends/suspect.jpg rel=lightbox><img src = legends/suspect.jpg height=100 width = 100/><br> ").addTo(map);
closure1 (markerA)
var ll = markerA.getLatLng();
document.querySelector('#userLat').value = ll.lat;
document.querySelector('#userLng').value = ll.lng;
marker.dragging.enable();
});
}
上面代碼的輸出是如果我選擇縱火。 我將在地圖上放置一個標記。 我的問題是,如果單擊該標記,如何使它可拖動?
順便說一下這段代碼
document.querySelector('#userLat').value = ll.lat;
document.querySelector('#userLng').value = ll.lng;
連接到兩個ID為userLat和useLng的文本框中。 如果拖動該標記,如何更新此文本框?
有幫助嗎? TY
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.