//弹出提示 const popup = L.popup(); // .setLatLng([39.92, 116.46]) // .setContent('I am a standalone popup.'); // .openOn(map); function onMapClick(e) { // popup // .setLatLng(e.latlng) // .setContent(`You clicked the map at ${e.latlng.toString()}`) // .openOn(map); L.marker(e.latlng).addTo(map).bindPopup('' + e.latlng + '').openPopup(); routes.push(e.latlng); // current = lines.push(L.polyline(routes, { color: 'red' }).addTo(map).bindPopup("这是折线")); // map.removeLayer(last); // last = current; if(lines.length>0) { map.removeLayer(lines[0]); // lines.shift(); } lines.push(L.polyline(routes, { color: 'red' }).addTo(map).bindPopup("这是折线")); } function printInformation(information) { alert(information); } function clearOneLine(a) { map.removeLayer(lines[a]); // lines.pop(); } // function addOnePoint(lng, lat) // { // }