1
我要添加在地圖上一個新的標記,當我點擊右鍵,添加新的標記,當我點擊地圖(OpenStreetMap的,單張JS)
function InitialiserCarte() {
var map = L.map('map').setView([48.866667, 2.333333], 17);
// create the tile layer with correct attribution
var tuileUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png';
var attrib='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors';
var osm = L.tileLayer(tuileUrl, {
minZoom: 8,
maxZoom: 17,
attribution: attrib
});
osm.addTo(map);
var marker = L.marker([48.866667, 2.333333]).addTo(map);}
上,我打電話與這個jQuery這個功能(負載的頁面)
$(document).ready(function(){
InitialiserCarte();
});
是否可以通過點擊操作動態添加標記?
可能與http://stackoverflow.com/questions/18388288/how-do-you-add-marker-to-map-using-leaflet-map-onclick-function-event-handl和http:/ /stackoverflow.com/questions/9912145/leaflet-how-to-find-existing-markers-and-delete-markers/24342585#24342585 – user2441511