Geo::Coder::Googlev3 - Google Maps v3 Geocoding API
use Geo::Coder::Googlev3; my $geocoder = Geo::Coder::Googlev3->new; my $location = $geocoder->geocode(location => 'Brandenburger Tor, Berlin'); my @locations = $geocoder->geocode(location => 'Berliner Straße, Berlin, Germany');
Use this module just like Geo::Coder::Google. Note that no apikey is used in Google's v3 API, and the returned data structure differs.
apikey
Please check also http://code.google.com/intl/en/apis/maps/documentation/geocoding/ for more information about Google's Geocoding API and especially usage limits.
$geocoder = Geo::Coder::Googlev3->new; $geocoder = Geo::Coder::Googlev3->new(language => 'de', gl => 'es');
Creates a new geocoding object.
The ua parameter may be supplied to override the default LWP::UserAgent object. The default LWP::UserAgent object sets the timeout to 15 seconds and enables the env_proxy option.
ua
LWP::UserAgent
timeout
env_proxy
The Geo::Coder::Google's oe and apikey parameters are not supported.
oe
The parameters region, language, and bounds are also accepted. The bounds parameter should be in the form:
region
language
bounds
[{lat => ..., lng => ...}, {lat => ..., lng => ...}]
$location = $geocoder->geocode(location => $location); @locations = $geocoder->geocode(location => $location);
Queries $location to Google Maps geocoding API. In scalar context it returns a hash reference of the first (best matching?) location. In list context it returns a list of such hash references.
The returned data structure looks like this:
{ "formatted_address" => "Brandenburger Tor, Pariser Platz 7, 10117 Berlin, Germany", "types" => [ "point_of_interest", "establishment" ], "address_components" => [ { "types" => [ "point_of_interest", "establishment" ], "short_name" => "Brandenburger Tor", "long_name" => "Brandenburger Tor" }, { "types" => [ "street_number" ], "short_name" => 7, "long_name" => 7 }, { "types" => [ "route" ], "short_name" => "Pariser Platz", "long_name" => "Pariser Platz" }, { "types" => [ "sublocality", "political" ], "short_name" => "Mitte", "long_name" => "Mitte" }, { "types" => [ "locality", "political" ], "short_name" => "Berlin", "long_name" => "Berlin" }, { "types" => [ "administrative_area_level_2", "political" ], "short_name" => "Berlin", "long_name" => "Berlin" }, { "types" => [ "administrative_area_level_1", "political" ], "short_name" => "Berlin", "long_name" => "Berlin" }, { "types" => [ "country", "political" ], "short_name" => "DE", "long_name" => "Germany" }, { "types" => [ "postal_code" ], "short_name" => 10117, "long_name" => 10117 } ], "geometry" => { "viewport" => { "southwest" => { "lat" => "52.5094785", "lng" => "13.3617711" }, "northeast" => { "lat" => "52.5230586", "lng" => "13.3937859" } }, "location" => { "lat" => "52.5162691", "lng" => "13.3777785" }, "location_type" => "APPROXIMATE" } };
The raw option may be set to a true value to get the uninterpreted, raw result from the API. Just the JSON data will be translated into a perl hash.
$raw_result = $geocoder->geocode(location => $location, raw => 1);
Accessor for the region parameter. The value should be a country code ("es", "dk", "us", etc). Use this to tell the webservice to prefer matches from that region. See the Google documentation for more information.
Accessor for the language parameter.
Accessor for the bounds parameter.
Slaven Rezic <srezic@cpan.org>
This package is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Geo::Coder::Google, Geo::Coder::Many.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Straße,'. Assuming CP1252
To install Geo::Coder::Googlev3, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Geo::Coder::Googlev3
CPAN shell
perl -MCPAN -e shell install Geo::Coder::Googlev3
For more information on module installation, please visit the detailed CPAN module installation guide.