Geo::C...oglev3(3pm)
π Geo::Coder::Googlev3 π
okay bestie, so this is the manual page for Geo::Coder::Googlev3, living in the User Contributed Perl Documentation section of your 3pm man pages. it's a whole module, it's iconic, let's get into it π¦
β¨ NAME β¨
Geo::Coder::Googlev3 β it's the Google Maps v3 Geocoding API wrapper, periodt π
πΈ SYNOPSIS πΈ
the vibe check, in code:
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');
like, you literally just do that. no cap β¨
π DESCRIPTION π
use this module exactly like Geo::Coder::Google, fr fr. BUT β and this is the plot twist β there's no "apikey" used in Google's v3 API, and the data structure that comes back is different. so don't go expecting the old shape, bestie, it's giving new era π
also, pls pls pls go read https://developers.google.com/maps/documentation/geocoding/ for more deets about Google's Geocoding API β especially the usage limits, because Google will absolutely notice if you're out here spamming requests π
π CONSTRUCTOR π
new
$geocoder = Geo::Coder::Googlev3->new;
$geocoder = Geo::Coder::Googlev3->new(language => 'de', gl => 'es');
creates a shiny new geocoding object. main character energy, honestly β¨
- the
uaparameter may be supplied to override the defaultLWP::UserAgentobject. the defaultLWP::UserAgentobject sets thetimeoutto 15 seconds and enables theenv_proxyoption. so it's already got good defaults, you don't have to do anything π - the Geo::Coder::Google's
oeparameter is not supported. nope. not a thing here. sorry bestie π - the parameters
region,language,bounds, andkeyare also accepted π«Ά - the
boundsparameter should be in this form:
[{lat => ..., lng => ...}, {lat => ..., lng => ...}]
- the parameter
sensorshould be set to the string"true"if the geocoding request comes from a device with a location sensor (seehttps://developers.google.com/maps/documentation/geocoding/#GeocodingRequests). there's no default β so if you need it, you gotta say it out loud π - by default queries are done using
http. by setting theuse_httpsparameter to a true value,httpsis used π (yes babe, use https, it's 2022 in the footer, be safe)
π¦ METHODS π¦
geocode
$location = $geocoder->geocode(location => $location);
@locations = $geocoder->geocode(location => $location);
queries $location to the Google Maps geocoding API. so in scalar context it returns a hash reference of the first (best matching?) location, and in list context it returns a list of such hash references. choose your context wisely, bestie, it changes everything π«Ά
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"
}
};
likeβ¦ look at all those address_components. it ATE. π
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. so no fancy stuff, just the straight-up goods:
$raw_result = $geocoder->geocode(location => $location, raw => 1);
region
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 π
language
accessor for the language parameter π
bounds
accessor for the bounds parameter π
sensor
accessor for the sensor parameter π
π AUTHOR π
Slaven Rezic <srezic@cpan.org> β ty for your service, king π
this package is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay.
π SEE ALSO π
Geo::Coder::GoogleGeo::Coder::Many
go read those too, bestie, they're the whole friend group π«Ά
and that's the whole page!! π this was perl v5.36.0, dated 2022-12-12 β a little vintage, a little iconic, and it's still serving. go geocode something cute β¨ππ¦
π¦ where this page comes from
- debian bookworm: libgeo-coder-googlev3-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libgeo-coder-googlev3-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libgeo-coder-googlev3-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libgeo-coder-googlev3-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libgeo-coder-googlev3-perl 0.17-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms