I'm trying to find a plug-in on leaflet in which the user will enter the address and the html (aka the plug-in) will geocode the location and will return a latitude and longitude. So I have try the Leaflet-Control Geocoder,but I am not able to the lat,long.

Does anyone have an example?

1 Answer 1


As per the Leaflet Control Geocoder plugin API documentation, you should:

  1. Attach an event on the "markgeocode" event of the L.Control.geocoder object.
  2. Read the event.geocode.center LatLng object that is passed to your event listener.
var geocoder = L.Control.geocoder()
.on('markgeocode', function(event) {
    var center = event.geocode.center;
    map.setView(center, map.getZoom());

Demo: http://playground-leaflet.rhcloud.com/robi/1/edit?html,output


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.