The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


Geo::Coder::Canada - Perl extension for getting longitude and latitude cordinates given a Canadian address. Also, provides reverse geocoding to return the nearest shipping address given a longitude and latitude point.


  use Geo::Coder::Canada;
  my $g = Geo::Coder::Canada->new;

  # Standard Geocoding...
  $g->addresst('Main St');
  if ($g->geocode) {
    my $latitude  = $g->latt;
    my $longitude = $g->long;
  else {
    my $error_msg = $g->error->message;

  # Intersection geocoding...
  $g->street1('Burrard Street');
  $g->street2('Robson Street');

  # Reverse geocoding...


This module provides a Perl frontend for the website XML API. It allows the programmer to convert from street address information to longitude and latitude coordinates as well as the reverse function. This module also provides some extra features like defining an address using a nearby cross street intersections and determining a the postal code for an address.



Returns a new Geo::Coder::Canada object.


Send the address information to and return the Geo::Coder::Canada::Response object. You are required to set the addresst, stno, city and prov methods or the postal method before calling geocode().


Send the latt/long values to and return a Geo::Coder::Canada::Response object. You are required to enter street1, street2, city and prov methods before calling geocode().


Send the intersection address information and return a Geo::Coder::Canada::Response object. You are required to set the latt and long methods before calling intersection_geocode().


Contains a reference to the Geo::Coder::Canada::Response object (in case you missed it during the request call)


Contains a reference to the Geo::Coder::Canada::Error object. This is only set when the original geocode request failed.


addresst(), stno(), street1(), street2(), city(), prov(), locate(), postal()

These methods contain basic get/set methods and provide no validation.


An optional parameter to limit the number of decimal places in the lat and long response values.


An optional value you can set which is returned back as sent. Used to match requests to response values?


Optional value to produce better accuracy on longitude and latitude values. Although this is not assured. See the site for more information.


Optional value to set if you have not given a postal address. in this case the postal address will be returned by and available in the response object. Only the values 1 or 0 are valid.


A decimal input value representing the latitude of the address.


A decimal input value representing the longitude of the address.


XML::Simple, LWP::UserAgent, HTTP::Request, URI


Jeff Anderson,

Copyright (c) 2006 Jeff Anderson. All rights reserved. This program is free software; you can redistribut it and/or modify it under the same terms as Perl itself.


Geo::Coder::Canada::Response, Geo::Coder::Canada::Error