Find the latitude and longitude of address using Geocoding API example

In my recent project I faced the task of doing translation of property address in form we usually use it into global coordinates, that can be plotted on the map. Using Google API services this task is quite easy. You can check example and source code below


Geocoding API javascript example

Enter any address below to locate it on the map

Using JavaScript

Example above is using JavaScript version of Geocoding API, so it is possible to call it through the browser. Source code is below:


Download geocoding source code here

Using HTTP

Another way to use Geocoding API is though HTTP GET request. This way is more suitable to beused in PHP scripts. All is needed is to make request to the URl below, substituting the real address.

http://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false

Response is JSON encoded object, you can see more sample at Google Geocoding API help page

2 comments

  1. I had search map like you in my site but my Question is how i can show search location co-ordinates in textfield …

Leave a Reply

Your email address will not be published.