Google has a very handy web service available for geocoding. Very often we require to know the longitude, latitude of a postcode, may be for finding distance between 2 places or any other reasons (who cares) and as always, Google is ready with the service before you realize you’ll need that
. This is the beauty of google – they thinks ahead.
To use the service, at first, you need to get a google api key for your site which takes less than 30 seconds from here.
Following is the typical format of the request string to get geocoding information:
http://maps.google.com/maps/geo?q=95678&output=json&oe=utf8&sensor=false&key=your_key_here
Description:
There are lot other options to be added. You can find official documentation here
Following is a simple geocoding script I wrote in PHP to get the lat/long of a postcode (it can be any address format other than postcode). Ask me in comments if you want the script, I’ll mail it to you.
Open the app in new window


#1 by Ryan McDermott on July 25th, 2009
Great script, I\’ve been looking for this! can you plz send me it?
thanks!
#2 by Imran on July 25th, 2009
Hi Ryan, Sent to your email address. Thanks a lot for coming.
#3 by steve on August 7th, 2009
thats just what ive been looking could you please send me the script?
#4 by Imran on August 7th, 2009
Hi Steve,
Sent it to your email. Thanks for coming.