GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Geo::Coder::Google::V2(3) User Contributed Perl Documentation Geo::Coder::Google::V2(3)

Geo::Coder::Google::V2 - Google Maps Geocoding API V2

  use Geo::Coder::Google;

  my $geocoder = Geo::Coder::Google->new();
  my $location = $geocoder->geocode( location => 'Hollywood and Highland, Los Angeles, CA' );

Geo::Coder::Google::V2 provides a geocoding functionality using Google Maps API V2.

Note: Google no longer supports the V2 API. There are no longer any V2 servers to connect to. Any attempt to use the V2 API will fail.

new
  $geocoder = Geo::Coder::Google->new();
  $geocoder = Geo::Coder::Google->new(host => 'maps.google.co.jp');
  $geocoder = Geo::Coder::Google->new(language => 'ru');
  $geocoder = Geo::Coder::Google->new(gl => 'ca');
  $geocoder = Geo::Coder::Google->new(oe => 'latin1');
    

Creates a new geocoding object.

When you'd like to query Japanese address, you might want to set host parameter, which should point to maps.google.co.jp. I think this also applies to other countries like UK (maps.google.co.uk), but so far I only tested with .com and .co.jp.

To specify the language of Google's response add "language" parameter with a two-letter value. Note that adding that parameter does not guarantee that every request returns translated data.

You can also set "gl" parameter to set country code (e.g. ca for Canada).

You can ask for a character encoding other than utf-8 by setting the oe parameter, but this is not recommended.

geocode
  $location = $geocoder->geocode(location => $location);
  @location = $geocoder->geocode(location => $location);
    

Queries $location to Google Maps geocoding API and returns hash reference returned back from API server. When you cann the method in an array context, it returns all the candidates got back, while it returns the 1st one in a scalar context.

When you'd like to pass non-ascii string as a location, you should pass it as either UTF-8 bytes or Unicode flagged string.

Returned data structure is as follows:

  {
    'AddressDetails' => {
      'Country' => {
        'AdministrativeArea' => {
          'SubAdministrativeArea' => {
            'SubAdministrativeAreaName' => 'San Francisco',
            'Locality' => {
              'PostalCode' => {
                'PostalCodeNumber' => '94107'
              },
              'LocalityName' => 'San Francisco',
              'Thoroughfare' => {
                'ThoroughfareName' => '548 4th St'
              }
            }
          },
          'AdministrativeAreaName' => 'CA'
        },
        'CountryNameCode' => 'US'
      }
    },
    'address' => '548 4th St, San Francisco, CA 94107, USA',
    'Point' => {
      'coordinates' => [
        '-122.397323',
        '37.778993',
        0
      ]
    }
  }
    
ua
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:

  $coder->ua->env_proxy;
    

You can also set your own User-Agent object:

  $coder->ua( LWPx::ParanoidAgent->new );
    

Tatsuhiko Miyagawa <miyagawa@bulknews.net>

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

Geo::Coder::Yahoo, <http://www.google.com/apis/maps/documentation/#Geocoding_Examples>

List of supported languages: <http://spreadsheets.google.com/pub?key=p9pdwsai2hDMsLkXsoM05KQ&gid=1>

2020-07-20 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.