var map = L.map('map').setView([51.505, -0.09], 13).setZoom(2);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {
foo: 'bar',
attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA'
}).addTo(map);
var marker = L.marker([0, 0], draggable = true).addTo(map);
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;
}
map.on('click', onMapClick);