get latitude & longitude as per address given for leaflet

vaibhav shah picture vaibhav shah · Apr 10, 2013 · Viewed 42.8k times · Source

In my project I am using leaflet to display points.

I am getting address from my database & want to show point for that particular address.

I haven't found anything which will give me latitude & longitude as per address provided.

Can anyone help me on this?

Answer

movAX13h picture movAX13h · Dec 12, 2015

If you want to use OpenStreetmaps for this, you can simply make a request (using jquery):

    $.get(location.protocol + '//nominatim.openstreetmap.org/search?format=json&q='+address, function(data){
       console.log(data);
    });

You'll get JSON objects containing (not only) lat and lon.