Gabor Cselle > WWW-YahooMaps-0.2 > WWW::YahooMaps

Download:
WWW-YahooMaps-0.2.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: 0.2   Source   Latest Release: WWW-YahooMaps-0.3

NAME ^

WWW::YahooMaps - Create links to Yahoo! Maps

SYNOPSIS ^

 use WWW::YahooMaps;

 #first method: PASSING ADDRESS BIT-BY-BIT
 my %addr = (
  "street" => "Rämistrasse 5",
  "city" => "8006 Zuerich",
  "country" => "ch",
  "language" => "de",
 );

 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";
 }


 if (my $url = WWW::YahooMaps::stringtolink("fr","fr","75017 Paris; 11 bis, rue Torricelli", 1)){
      print "url3 $url\n";
 }

Code above will print:

url1 http://de.maps.yahoo.com/py/lg:de/lc:de/maps.py?BFCat=&Pyt=Tmap&newFL=&addr=R%E4mistrasse%205&csz=8006%20Zuerich&country=ch

url2 http://maps.yahoo.com/py/lg:/lc:/maps.py?BFCat=&Pyt=Tmap&newFL=&addr=101%20Morris%20Street&csz=Sebastopol,%20CA%2095472&country=us

url3 http://fr.maps.yahoo.com/py/lg:fr/lc:fr/maps.py?BFCat=&Pyt=Tmap&newFL=&addr=11%20bis,%20rue%20Torricelli&csz=75017%20Paris&country=fr

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, however adding it leads to a much more accurate map.

The value of city can be either a postal code or a city name, however 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 "; Paris" or "\n Zurich". Pass swap = 1 if you have a string where the city comes first, address second, e.g.: "New York, NY; Wall Street".

Countries

Yahoo offers maps for several countries - use the domain name (ISO 3166 2-letter code) for the {country} key. Currently available countries are:

 - Austria (at)
 - Belgium (be)
 - Canada (ca) - only in combination with language = "us"
 - France (fr)
 - Germany (de)
 - Italy (it)
 - Luxembourg (lu)
 - Netherlands (nl)
 - Portugal (pt)
 - Spain (es)
 - Switzerland (ch)
 - U.S.A. (us) - only in combination with language = "us"
 - United Kingdom (gb/uk)

testcountry()

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

Languages

Note that you can display maps for Germany in French, by passing "fr" as {language} and "de" as {country}. Supported languages are (again, use ISO 3166 codes for language):

 - American English (us) - only in combination with country = "us"
 - British English (uk)
 - French (fr) 
 - German (de)
 - Italian (it)
 - Spanish (es)

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, gaborcselle@yahoo.de

THANKS TO ^

Ed Freyfogle, who wrote the original version.

REVISIONS ^

0.1 : first version

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

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/

syntax highlighting: