Geo::Coder::CA - Provides a Geo-Coding functionality using https://geocoder.ca for both Canada and the US.
Version 0.15
use Geo::Coder::CA;
my $geo_coder = Geo::Coder::CA->new();
my $location = $geo_coder->geocode(location => '9235 Main St, Richibucto, New Brunswick, Canada');
Geo::Coder::CA provides an interface to geocoder.ca. Geo::Coder::Canada no longer seems to work.
$geo_coder = Geo::Coder::CA->new();
my $ua = LWP::UserAgent->new();
$ua->env_proxy(1);
$geo_coder = Geo::Coder::CA->new(ua => $ua);
$location = $geo_coder->geocode(location => $location);
# @location = $geo_coder->geocode(location => $location);
print 'Latitude: ', $location->{'latt'}, "\n";
print 'Longitude: ', $location->{'longt'}, "\n";
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:
$geo_coder->ua()->env_proxy(1);
You can also set your own User-Agent object:
my $ua = LWP::UserAgent::Throttled->new();
$ua->throttle('geocoder.ca' => 1);
$geo_coder->ua($ua);
$location = $geo_coder->reverse_geocode(latlng => '37.778907,-122.39732');
Similar to geocode except it expects a latitude/longitude parameter.
You can also run this module from the command line:
perl CA.pm 1600 Pennsylvania Avenue NW, Washington DC
Nigel Horne, <njh@bandsman.co.uk>
Based on Geo::Coder::GooglePlaces.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Lots of thanks to the folks at geocoder.ca.
Please report any bugs or feature requests to the author. This module is provided as-is without any warranty.
Should be called Geo::Coder::NA for North America.
Geo::Coder::GooglePlaces, HTML::GoogleMaps::V3
Copyright 2017-2025 Nigel Horne.
This program is released under the following licence: GPL2