NAME
Geo::Coder::Google::V3 - Google Maps Geocoding API V3
SYNOPSIS
use Geo::Coder::Google;
my $geocoder = Geo::Coder::Google->new(apiver => 3);
my $location = $geocoder->geocode( location => 'Hollywood and Highland, Los Angeles, CA' );
DESCRIPTION
Geo::Coder::Google::V3 provides a geocoding functionality using Google Maps API V3.
METHODS
- new
-
$geocoder = Geo::Coder::Google->new(apiver => 3); $geocoder = Geo::Coder::Google->new(apiver => 3, language => 'ru'); $geocoder = Geo::Coder::Google->new(apiver => 3, gl => 'ca'); $geocoder = Geo::Coder::Google->new(apiver => 3, oe => 'latin1');
To specify the language of Google's response add
language
parameter with a two-letter value. Note that adding that parameter does not guarantee that every request returns translated data.You can also set
gl
parameter to set country code (e.g. ca for Canada).You can ask for a character encoding other than utf-8 by setting the oe parameter, but this is not recommended.
- geocode
-
$location = $geocoder->geocode(location => $location); @location = $geocoder->geocode(location => $location);
Queries $location to Google Maps geocoding API and returns hash reference returned back from API server. When you cann the method in an array context, it returns all the candidates got back, while it returns the 1st one in a scalar context.
When you'd like to pass non-ascii string as a location, you should pass it as either UTF-8 bytes or Unicode flagged string.
- ua
-
Accessor method to get and set UserAgent object used internally. You can call env_proxy for example, to get the proxy information from environment variables:
$coder->ua->env_proxy;
You can also set your own User-Agent object:
$coder->ua( LWPx::ParanoidAgent->new );
AUTHOR
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
Geo::Coder::Yahoo, http://www.google.com/apis/maps/documentation/#Geocoding_Examples
List of supported languages: http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1