My fork of GoGeocode- a PHP wrapper for Google Maps V3 API

One of Sapling's core matching criteria is distance. In an attempt to get a little bit of abstraction from the core geocoding services, I looked through several libraries for one that would suit my project.

I found GoGeocode, a PHP library that gave me the abstraction I wanted from hitting the APIs directly, and also provided some sanity checks on the responses. Not only was there error checking, but gogeocode takes back the XML data returned by Google Maps and spits back a nice PHP array, for instance.

The only problem is that GoGeocode, although it was last updated 6 months ago, does not feature support for Google Map's V3 API. The V3 API is a lot more friendly than V2, including allowing 2500 requests per day without an API key.

Naturally, I forked the library on Github and added support for key-less queries of the V3 api. I only needed to obtain a latitude and longitude for my own needs, but data for country, municipality, and several levels of areas of administration are available too.

If you're interested, check out my repo here.

Here's a quick example of how you might use the updated Geocode library.

Example (Geocode an address using Google's geocoding service)

require('GoogleGeocode.php');
$geo = new GoogleGeocode();
$result = $geo->geocode( "13 Oak Drive, Hamilton, NY, 13346" );
print_r( $result );

Outputs:

Array(
    'Response' => array(
        'Status' => 'OK',
        'Request' => 'postal_code'
    ),
    'Geometry' => array(
        'Latitude' => (float) 42.8194512,
        'Longitude' => (float) -75.5363587
    )
)