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:
<?php $key //your api key $address //address to geocode $url = 'http://maps.google.com/maps/geo?q='.urlencode($address).'&output=json&sensor=false&key='.$key; $data = file_get_contents($url); $loc = json_decode($data); $lat = $loc->Placemark->Point->coordinates; $long = $loc->Placemark->Point->coordinates; ?>