How to geocode an address using Google and php

Google has some amazing services, one of my favourites would have to be the ability to geocode an address and get not only the lat/long but a clean, well formatted address back. 

How you say... Easy!

Get yourself an api key from here: http://code.google.com/apis/maps/signup.html

use the following php code:

Placemark[0]->Point->coordinates[1]; $long = $loc->Placemark[0]->Point->coordinates[0]; ?>

Thanks Google!

Add new comment

Filtered HTML

  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo].
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockcode>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.