im trying to make a map with Leaflet when i search a place it give me the Latitude, Longitude and the adresse of the place,I want to ask if there is a function that let me save the adresse in a variable.
Picture example
/*===================================================
OSM LAYER
===================================================*/
let lat;
let nom;
var x;
let lon;
var map = L.map('map').setView([9.561555499999997,33.892166], 4);
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
osm.addTo(map);
map.on('click', function (e) {
lat=e.latlng.lat;
lon = e.latlng.lng;
document.getElementById('latitude').textContent = lat;
document.getElementById('longitude').textContent = lon;
x=document.getElementById('latitude').innerHTML;
});
/*===================================================
MARKER
===================================================*/
var singleMarker = L.marker([28.25255,83.97669]);
singleMarker.addTo(map);
var popup = singleMarker.bindPopup('This is a popup')
popup.addTo(map);