Geo::Coder::GoogleMaps - Google Maps Geocoding API
Version 0.4
WARNING WARNING WARNING
There is a huge API change between version 0.2 and 0.3 ! Please see the documentation of the geocode() method !
This module provide Google Maps API. Please note that this module use Tatsuhiko Miyagawa's work on Geo::Coder::Google as base (http://search.cpan.org/~miyagawa/).
In fact it's a fork of Mr Miyagawa's module. Geo::Coder::GoogleMaps use the default JSON data type as default output but also support XML/KML.
The direct output of the geocode() method is no longer a Geo::Coder::GoogleMaps::Location but a Geo::Coder::GoogleMaps::Response. This one contains a list of Geo::Coder::GoogleMaps::Location objects which can be, individually, exported to any of the supported format.
use Geo::Coder::GoogleMaps; my $gmap = Geo::Coder::GoogleMaps->new( apikey => 'abcd' , output => 'xml'); my $response = $gmap->geocode(location => '88 rue du chateau, 92600, Asnières sur seine, France'); if( $response->is_success() ){ my $location = $response->placemarks()->[0]; print $location->latitude,',',$location->longitude,"\n"; $location->toKML()->toString(); # is absolutly equivalent to $location->toKML(1); }
The object constructor it takes the following parameters :
apikey : your Google API key (only parameter mandatory). ua : a LWP::UserAgent object. If not provided a new user agent is instanciates. host : the google map service url (default is: maps.google.com) output : the output method between xml, kml and json (csv support plan for futur release). Default is json.
Example:
my $gmap = Geo::Coder::GoogleMaps->new( apikey => 'abcdef', host => 'maps.google.fr', output => 'xml');
There is a huge API change between version 0.2 and 0.3 ! This method do not returns placemarks directly anymore !!
Get a location from the Google Maps API. It return a Geo::Coder::GoogleMaps::Response object.
my $response = $gmap->geocode(location => '88 rue du chateau, 92600, Asnières sur seine, France'); print $response->placemarks()->[0]->Serialize(1) if( $response->is_success() ) ;
Please note that for the moment the geocode methode rely on JSON::Syck to parse the Google's output and ask for result in JSON format.
In futur release the 'output' from the constructor will mainly be used to define the way you want this module get the data.
The dependency to JSON::Syck and XML::LibXML will be removed to be optionnal and dynamically load.
Geo::Coder::Google (the original module) is from Tatsuhiko Miyagawa.
Arnaud Dupuis, <a.dupuis at infinityperl.org>
<a.dupuis at infinityperl.org>
Please report any bugs or feature requests to bug-geo-coder-googlemaps at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Geo-Coder-GoogleMaps. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-geo-coder-googlemaps at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Geo::Coder::GoogleMaps
You can also look for information at:
Infinity Perl:
http://www.infinityperl.org
Google Code repository
https://code.google.com/p/geo-coder-googlemaps/
Google Maps API documentation
http://code.google.com/apis/maps/documentation/geocoding/
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Geo-Coder-GoogleMaps
CPAN Ratings
http://cpanratings.perl.org/d/Geo-Coder-GoogleMaps
RT: CPAN's request tracker
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Geo-Coder-GoogleMaps
Search CPAN
http://search.cpan.org/dist/Geo-Coder-GoogleMaps
Slaven Rezic (SREZIC) for all the patches and his useful reports on RT.
Copyright 2007-2010 Arnaud DUPUIS, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Geo::Coder::GoogleMaps, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Coder::GoogleMaps
CPAN shell
perl -MCPAN -e shell install Geo::Coder::GoogleMaps
For more information on module installation, please visit the detailed CPAN module installation guide.