Created
April 1, 2021 06:08
-
-
Save m3l1nd4/a64873fe2ce1460edc062d3b3f0f05aa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Move on the map and add marker to a chosen position | |
function moveOnTheMap(map, chosenPositionMarker) { | |
map.on("click", function (e) { | |
lat = e.latlng.lat; | |
lon = e.latlng.lng; | |
document.getElementById("shop-location").value = lat + " " + lon; | |
let redIcon = new L.Icon({ | |
iconUrl: "https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-2x-red.png", | |
shadowUrl: "https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.7.7/images/marker-shadow.png", | |
iconSize: [25, 41], | |
iconAnchor: [12, 41], | |
popupAnchor: [1, -34], | |
shadowSize: [41, 41], | |
}); | |
if (chosenPositionMarker != undefined) | |
map.removeLayer(chosenPositionMarker); | |
chosenPositionMarker = L.marker([lat, lon], { icon: redIcon }) | |
.addTo(map) | |
.bindPopup("Your chosen position.") | |
.openPopup(); | |
map.setView([lat, lon], 14); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment