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::YahooJapan - a simple wrapper for Yahoo Japan Geocoder API


  use Geo::Coder::YahooJapan;
  $r = lookup( $address_in_japanese_characters );
  my ($lat, $lng) = ( $r->{latitude}, $r->{longitude} ); # coordinate in WGS87.

  # if you want to get result in TOKYO datum, specify it in option.
  $r = lookup( $address_in_japanese_characters, { datum => 'tokyo' } );

  # if address is ambiguous and the server returns multiple items
  $r = lookup( $address_in_japanese_characters );
  # $r->{latitude} and $r->{longitude} contains coordinate of first item.
  ($lat, $lng) = ( $r->{latitude}, $r->{longitude} );

  # $r->{hits} has the number of candidates.
  if ( $r->{hits} > 1 ) {
        # and $r->{items} contains each candidates infomation.
        foreach ( $r->{items} ) {
                print join "\t", ( $_->{title}, $_->{latitude}, $_->{longitude} );
                print "\n";


Geo::Coder::YahooJapan is a wrapper for Yahoo Japan Geocoder API that is used by the official Yahoo Japan's local search widget . This module converts the coordinate into WGS84 from TOKYO datum which is returned by API server.

lookup(address, opts)

Lookup is an only method in this package that returns coordinate information in an hash reference. When address is not enough precise, the server returns multiple candidates. These candidatse are found in $response->{items}. You can determine geocoding result has multiple candidates or not by seeing $response->{hits}.

You can specify the address in UTF8, SHIFT_JIS, EUC_JP. But the API server does not understand ISO-2022-JP, so you need convert into other character set if your address is written in ISO-2022-JP. In $opts->{num}, you can specify the number of candidates you want to receive when multiple items are found. Default value is 10. If you want to get results in other datum, not in WGS84, set the datum name in $opts->{datum}. the value is passed to Location::GeoTool and it converts them properly.


HTTP::Request LWP::UserAgent Location::GeoTool


KUMAGAI Kentaro <>