I have a problem today with the Nominatim reverse geocoder for Leaflet.
I found a solution on github : https://github.com/perliedman/leaflet-control-geocoder , but I don't know how to use it.
I can use the mapzen solution for the normal geocoding but for the reverse it doesn't work…
In fact, I have a HTML page which contains a leaflet map at the right, and a toggle menu at the left. In this menu, I have a mathematic tool which make some treatments to find some Lat Long coordinates.
Those coordinates appears in a with the dd.dddddddd format.
And I want this LatLong result to be located on my map with a point and a toggle popup.
I've made a little Schema to illustrate my needs :
I've tried to put a "L.popup" solution but it doesn't work :
L.popup();
function onMapClick(e) {
popup
.setLatLng(['sch-lat','sch-long'])
.setContent("The coordinates are" + ['sch-lvpk-lat','sch-lvpk-long'].toString())
.openOn(map);
}
map.on('click', onMapClick);
The 'sch-lat','sch-long' are the html inputs in which we have lat long values.
And I also tried to make a Nominatim reverse geocoding by using leaflet-control-geocoder but I don't know how to use it…
I made this :
L.control.showAll({bounds: L.latLngBounds(L.latLng(41.058, 9.257), L.latLng(51.009, -5.295))}).addTo(map);
L.control.geocoder('mapzen-vv6kj8z').addTo(map);
L.control.geocoder('Nominatim').addTo(map);
L.control.scale({options: {position: 'bottomleft',maxWidth: 100,metric: true,imperial: false,updateWhenIdle: false}}).addTo(map);
L.control.mousePosition().addTo(map);
But it doesn't work neither…
If you have another solution I accept it 😀
Best Answer
This may work: