Created
March 1, 2012 15:35
-
-
Save kenmickles/1950555 to your computer and use it in GitHub Desktop.
Simple PHP geocode function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function geocode($address) { | |
$url = 'http://maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false'; | |
$response = json_decode(file_get_contents($url), 1); | |
if ( isset($response['results'][0]) ) { | |
$ll = $response['results'][0]['geometry']['location']; | |
return array($ll['lat'], $ll['lng']); | |
} | |
return false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment