Source: site.view [edit]
Function name: parseAddress2
Arguments: addrStr
Description: From a freeform address string, returns lat/long, street, city, zip using a free service from Yahoo
Page type: webl
Render function:  
Module: global

Page source:

var res = [];

addrStr = Url_Decode(addrStr);

var TextVal = fun(P, fieldname, elt)
   var E = Elem(P, fieldname) inside elt; 
   return (Str_Trim(Text(E[0])) ? "")
end;
           

var P = GetURL("http://gws2.maps.yahoo.com/findlocation?pf=1&locale=en_US&flags=J&offset=15&gflags=&start=0&count=100&q=" + Url_Encode(addrStr),
  [. appid="wubhuboaa".]);
        
var Result = Elem(P, "Results");
if Size(Result) > 0 then
  [.
     latitude=TextVal(P, "latitude", Result[0]),
     longitude=TextVal(P, "longitude", Result[0]),
     radius=TextVal(P, "radius", Result[0]),
     address=TextVal(P, "line1", Result[0]),
     house=TextVal(P, "house", Result[0]),
     street=TextVal(P, "street", Result[0]),
     unit=TextVal(P, "unit", Result[0]),
     postal=TextVal(P, "postal", Result[0]),
     city=TextVal(P, "city", Result[0]),
     county=TextVal(P, "county", Result[0]),
     neighborhood=TextVal(P, "neighborhood", Result[0]),
     statecode=TextVal(P, "statecode", Result[0]),
     state=TextVal(P, "state", Result[0]),
     zip=TextVal(P, "uzip", Result[0]),
     country=TextVal(P, "country", Result[0]),
     countrycode=TextVal(P, "countrycode", Result[0]),
     woeid=TextVal(P, "woeid", Result[0]),
     markup=Markup(P)
  .]
else
  Markup(P)
end;