Skip to content

Instantly share code, notes, and snippets.

@psycharo-zz
Created June 1, 2012 19:29
Show Gist options
  • Save psycharo-zz/2854584 to your computer and use it in GitHub Desktop.
Save psycharo-zz/2854584 to your computer and use it in GitHub Desktop.
function addressToCoordinates($address) {
$BASE_URL = 'http://maps.googleapis.com/maps/api/geocode/json';
$socket = new HttpSocket();
$args = array('address' => $address,
'sensor' => 'false');
$results = json_decode($socket->get($BASE_URL, $args));
if ($results != null && sizeof($results->results) >= 1) {
$loc = $results->results[0]->geometry->location;
return $loc;
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment