Skip to content

Instantly share code, notes, and snippets.

@anselmobattisti
Created March 13, 2010 00:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anselmobattisti/330990 to your computer and use it in GitHub Desktop.
Save anselmobattisti/330990 to your computer and use it in GitHub Desktop.
<?php
/**
* Retorna dados sobre o endereço
*
* @url http://code.google.com/apis/maps/documentation/v3/reference.html#GeocoderRequest
*
* @autor Anselmo Battisti (anselmobattisti@gmail.com)
*/
define("URL","http://maps.google.com/maps/api/geocode/json?address=");
class Sistema_Geocode
{
/**
* getGeocode
*
* @param $endereco
*
* @return Object
*/
public static function getGeocode($endereco){
$url = URL.urlencode(utf8_encode($endereco))."&sensor=true";
$handle = fopen($url,"r");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);
return json_decode($contents);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment