所以我有这个脚本:“
<div id="mapContainer"></div>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"></script>
<script>
var map = L.map('mapContainer').setView([46.770439, 23.591423], 13);
var layer = L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png'{attribution: '© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'}).addTo(map);
var marker = L.marker([46.763758, 23.609010]).addTo(map);
var popup = L.popup();
var theMarker = {};
map.on('click',function(e){
lat = e.latlng.lat;
lon = e.latlng.lng;
console.log("You clicked the map at LAT: "+ lat+" and LONG: "+lon );
//Add a marker to show where you clicked.
theMarker = L.marker([lat,lon]).addTo(map).bindPopup('hi').openPopup();});
我生成了地图,我想在其上添加更多标记,但问题是我不知道如何为这些标记进行选择。你能帮助我吗? 我只想要一个标签,它可以向我显示可用的标记,并让我选择要在地图上想要放置的标记之一。