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::GoogleMaps - Google Maps Geocoding API


Version 0.12


This module provide Google Maps API. Please note that this module use Tatsuhiko Miyagawa's work on Geo::Coder::Google as base (

In fact it's a fork of Mr Miyagawa's module. Geo::Coder::GoogleMaps use the default JSON data type as default output but also support XML/KML.

The direct output of the geocode() method is now a Geo::Coder::GoogleMaps::Location object which can be exported to any of the supported format.

        use Geo::Coder::GoogleMaps;
        my $gmap = Geo::Coder::GoogleMaps->new( apikey => 'abcd' , output => 'xml');
        my $location = $gmap->geocode(location => '88 rue du chateau, 92600, Asnières sur seine, France');
        print $location->latitude,',',$location->longitude,"\n";
        $location->toKML()->toString(); # is absolutly equivalent to $location->toKML(1);



The object constructor it takes the following parameters :

        apikey : your Google API key (only parameter mandatory).
        ua : a LWP::UserAgent object. If not provided a new user agent is instanciates.
        host : the google map service url (default is:
        output : the output method between xml, kml and json (csv support plan for futur release). Default is json.


        my $gmap = Geo::Coder::GoogleMaps->new( apikey => 'abcdef', host => '', output => 'xml');


Get a location from the Google Maps API. It return a list (in list context) of Geo::Code::GoogleMaps::Location objects or the first one in a scalar context.

        my $location = $gmap->geocode(location => '88 rue du chateau, 92600, Asnières sur seine, France');
        print $location->Serialyze ;

Please note that for the moment the geocode methode rely on JSON::Syck to parse the Google's output and ask for result in JSON format.

In futur release the 'output' from the constructor will mainly be used to define the way you want this module get the data.

The dependency to JSON::Syck and XML::LibXML will be removed to be optionnal and dynamically load.


Geo::Coder::Google (the original module) is from Tatsuhiko Miyagawa.

Arnaud DUPUIS, <a.dupuis at>


Please report any bugs or feature requests to bug-geo-coder-googlemaps at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc Geo::Coder::GoogleMaps

You can also look for information at:



Copyright 2007 Arnaud DUPUIS and Nabla Development, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

1 POD Error

The following errors were encountered while parsing the POD:

Around line 38:

Non-ASCII character seen before =encoding in 'Asnières'. Assuming UTF-8