2021-04-19 20:34:09 +02:00
|
|
|
var map = L.map('map').setView([51.505, -0.09], 13).setZoom(2);
|
2021-03-28 20:40:17 +02:00
|
|
|
|
2021-04-19 20:34:09 +02:00
|
|
|
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {
|
|
|
|
foo: 'bar',
|
|
|
|
attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
|
|
|
|
}).addTo(map);
|
|
|
|
|
|
|
|
var marker = L.marker([0, 0], draggable = true).addTo(map);
|
2021-03-28 20:40:17 +02:00
|
|
|
|
|
|
|
var LatLng = marker.getLatLng();
|
|
|
|
|
|
|
|
let coordinates_input = document.getElementById('latlng');
|
|
|
|
|
|
|
|
function onMapClick(e) {
|
|
|
|
marker.setLatLng(e.latlng);
|
|
|
|
LatLng = marker.getLatLng();
|
|
|
|
// console.log(LatLng);
|
|
|
|
lat = LatLng['lat'];
|
|
|
|
lng = LatLng['lng'];
|
|
|
|
coordinates_input.value = lat + ', ' + lng;
|
|
|
|
}
|
|
|
|
|
2021-04-19 20:34:09 +02:00
|
|
|
map.on('click', onMapClick);
|