JQuery – Getting a Latitude & Longitude from address

I had a client realize today that their dealer search by radius function wasn’t working anymore so I dug in to find out why. The cause turns out to be the service we were using to geocode was no longer functioning which is rational since it was sevceral years old and before yahoo or google was offering geocoding.

Basically they need the dealers address and latitude and longitude to be added to the database so that when a user selects a search radius my coldfusion code does it’s formula which uses the lat & lon. Now the issue was that the lat & lon was no longer being entered into the database so some dealers werent being found… aka problem!

So I searched around and there was not really on info on just getting the lat & lon from an address with google geocoder. The client adds the address into their admin and then it needs to fetch the lat & lon and deposit it into db and that’s why I need to just use an address to get them.

I did find a few demos here and there that would get and display the lat & lon but they all seemed to get it via backend code so that didn’t help and all were straight js and I was hoping for some jquery goodness but nothing….. Turns out it was pretty easy, so I am posting it here so that there is finally something up with jquery as an example.

[code:html]

Which produces:

721 Thompson Ave, Millville, OH 45103, USA
Lat: 36.097338
Lon: -86.7834617

Now of course I wouldn’t output that like that I would enter them into db but at least you can see where to grab them from.

Leave a Reply

Your email address will not be published. Required fields are marked *