Kudos to Chauncey Thorn for this fun little hack to use Google for Geocoding that he posted on a FLOSS mailing list/ forum. Google would probably notice, mind, and shut down enterprise level use, but I imagine informal web services like this will put pricing pressure on geocoding vendors, while increasing number of apps that take advantage of geographic data.
Posted by Geodog at May 13, 2005 12:42 AM | TrackBack@params string full address
@return assoc array
$location = array('lat' => $lat, 'lng' => $lng)function map_geocoder($address)
{
$address = urlencode($address);
$response = drupal_http_request('http://maps.google.com/maps?q='.$address);// let find the lat/lng in the $response->data
preg_match("//",
$response->data, $matches);// cleaning up
$match = preg_split('/ /',$matches[0]);
$lat = str_replace('lat=','',$match[1]);
$lat = str_replace('"','',$lat);
$lng = str_replace('lng=','',$match[2]);
$lng = str_replace('/>$lng = str_replace('"','',$lng); // finally ...
$location['lat'] = $lat;
$location['lng'] = $lng;return $location;
}
My apologies, but my web hoster has turned off commenting, due to a flood of obscene spam bringing the server to its knees. I hope to have this weblog transitioned over to Wordpress in the near future, so that I can have commenting up and working again. Until then, please feel free to send me your comments via my email contact form.. Please ignore everything below this comment.