WWW::YahooMaps

Back to >> Gabor Cselle Homepage

YourGMap New: Use YourGMap to build your own maps in
less than five minutes. No Javascript or HTML needed.

Looking for maps of the U.S. or Canada? Go to Yahoo Maps!

Looking for maps of Europe (Germany, France, Switzerland, Italy, UK, etc.)? Well, Yahoo Maps Europe shut down.

You could use Maporama, which I like - or you could search the local Yahoos (www.yahoo.de, www.yahoo.co.uk, etc.) for maps.

NAME

WWW::YahooMaps - Create links to Yahoo! Maps

Download here: WWW-YahooMaps-0.3.tar.gz


SYNOPSIS

 use WWW::YahooMaps;

 #first method: PASSING ADDRESS BIT-BY-BIT
 my %addr = (
  "street" => "168 Madison",
  "city" => "Chicago, IL",
  "country" => "us",
  "language" => "us",
 );

 if (my $url = WWW:YahooMaps::hashreftolink(\%addr)){
      print "url1 $url\n";
 }

 #second method: ADDRESS INFO IN STRING
 #separators can be ";" or newline "\n"
 #street should come before city
 #pass an additional 1 at the end if you want to pass city first
 if (my $url = WWW::YahooMaps::stringtolink("us","us","101 Morris Street; Sebastopol, CA 95472")){
      print "url2 $url\n";
 }

 #third method: PASSED TO FUNCTION BIT-BY-BIT
 if (my $url = WWW::YahooMaps::stringtolink("us","us","145 Rogers Drive; Oklahoma City, OK", 1)){
      print "url3 $url\n";
 }


DESCRIPTION

Methods

hashreftolink()

Pass a reference to a hash to hashreftolink() and get a link to the corresponding Yahoo! map.

The keys of the hash are street (optional), city, country and language. The values of the keys country and language must be valid ISO 3166 two letter codes, and can be tested by the functions testcountry() and testlanguage() respectively.

The key, value pair street is optional, but adding it leads to a much more accurate map.

The value of city can be either a postal code or a city name, and adding both produces much more accurate map links. If a city name is ambiguous, for example there are multiple cities with that name, the link will lead to a page with links to the various cities of that name.

stringtolink()

Or, if you have a ready-made string with the adress info, pass it to stringtolink().

The parameters are country, language, string and swap. In string, street and city should be separated by a semicolon ";" or a newline "\n". Since street is optional, you can also pass "; New York, NY" or "\n San Francisco, CA". Pass swap = 1 if you have a string where the city comes first, address second, e.g.: "New York, NY; Wall Street".

Countries

Yahoo had offered maps for several countries, but has cancelled those products. For flexibility and backward compatibility, the countries option was kept; it defaults to "us". Use the domain name (ISO 3166 2-letter code) for the {country} key. The only option supported is:

  - U.S.A. (us) - only in combination with language = "us"
  - Canada (ca) - defaults to "us"

testcountry()

Use testcountry() to determine which countries are available, e.g.: testcountry("us") => returns 1, testcountry("tv") => returns 0.

Languages

This option was also kept in for backward compatibility. The only supported option is the default:

 - American English (us) - only in combination with country = "us"

testlang()

Use testlang() to determine which languages are available, e.g.: testlang("es") => returns 1, testlang("dk") => returns 0.

The language also determines which Yahoo server is used - the servers for language="us" are in the US, while servers for all others are in Europe.

If Yahoo can't find the exact address you pass, it will show the user its best guess with some alternative links.


REQUIREMENTS

uses URI::Escape.


AUTHOR

Gabor Cselle, gabor (at) student [dot] ethz [dot] ch


THANKS TO

Ed Freyfogle, who came up with the idea and wrote a first draft.


REVISIONS

0.1 : first version

0.2 : added Canada to countries, forces language="us" for US/CA, added docs for testcountry() and testlang()

0.3 : Yahoo cancelled all non-US maps products; new version allows language="us", counrty="us"/"ca" only


SEE ALSO

Find lists of ISO 3166 country codes here: http://dir.yahoo.com/Reference/Standards/International_and_Regional_Standards_Bodies/International_Organization_for_Standardization__ISO_/ISO_Country_Codes/