答え:
- CPAN
Geo::Coder::Google
オブジェクトをダウンロードします。
- V3.pmオブジェクトに移動します。
- このモジュールをコードにドロップします。
sub reverseGeocode {my $self = shift;
my %param;
if (@_ % 2 == 0) {
%param = @_;
} else {
$param{location} = shift;
}
my $location = $param{location}
or Carp::croak("Usage: reverseGeocode(location => \$location)");
if (Encode::is_utf8($location)) {
$location = Encode::encode_utf8($location);
}
my $uri = URI->new("http://$self->{host}/maps/api/geocode/json");
my %query_parameters = (latlng => $location);
$query_parameters{language} = $self->{language} if defined $self->{language};
$query_parameters{region} = $self->{region} if defined $self->{region};
$query_parameters{oe} = $self->{oe};
$query_parameters{sensor} = $self->{sensor} ? 'true' : 'false';
$uri->query_form(%query_parameters);
my $url = $uri->as_string;
if ($self->{client} and $self->{key}) {
$query_parameters{client} = $self->{client};
$uri->query_form(%query_parameters);
my $signature = $self->make_signature($uri);
# signature must be last parameter in query string or you get 403's
$url = $uri->as_string;
$url .= '&signature='.$signature if $signature;
}
次に、次のように使用します。
my $location = $geocoder->reverseGeocode(location => '40.7837366863403,-73.9882784482727');
次に、次のように戻りオブジェクトにアクセスできます。
print $location->{formatted_address};
アドレスの詳細な部分を確認するには、ガイドとして次のリンクを参照してください:
https ://developers.google.com/maps/documentation/geocoding/