Google geocoding class
Geocoding is the process of converting addresses (like “1600 Amphitheatre Parkway, Mountain View, CA”) into geographic coordinates (like latitude 37.423021 and longitude -122.083739), which you can use to place markers or position the map. The Google Maps API Geocoding Service provides a direct way to access a geocoder via an HTTP request.
About
This PHP class was created based on the classes of Tijs Verkoyen, my colleague at Netlash.
It can be used to geocode addresses or reverse geocode latitudes and longitudes in a very easy way.
Documentation
The class is well documented inline. If you use a decent IDE you’ll see that each method is documented with PHPDoc.
Github
Examples, documentation and the class itself can be found on Github.
i have tried you class, but something doesn’t work
when i use your example and echo $result i get Array
is there a small index.php file that i can download or just a little peace of code that you could send me to see the class actually working?
many tnx,
de wit yves
14 okt 09 om 16:58
Yves,
the result is indeed an Array.
Just var_dump the result to see what’s in the array.
$geo = new GoogleGeocoding();
$result = $geo->getInfo('ajuinlei 1, 9000 Gent, Belgium');
var_dump($result);
You can use different parts of the array and echo them. e.g.
echo $result['coordinates']['lng'];
Dextro
14 okt 09 om 23:28