Link | tsp_geocode |
Author | Jason Huck |
Category | Utility |
Version | 8.x |
License | Public Domain |
Posted | 08 Feb 2006 |
Updated | 21 Feb 2006 |
More by this author... |
This is a quick'n'dirty tag to retrieve coordinate data using the free service at geocoder.us. Per their terms of service, it is free for non-commercial use. Returns a map containing the components of the street address along with longitude and latitude. Returns null if the address could not be found. Only works with US addresses.
var('address') = '1815 Griffin Road, Dania Beach, FL 33004'; var('coordinates') = tsp_geocode($address); if($coordinates->size); 'Latitude: ' + $coordinates->find('latitude') + '
\n'; 'Longitude: ' + $coordinates->find('longitude') + '
\n'; 'Street: ' + $coordinates->find('street') + '
\n'; 'City: ' + $coordinates->find('city') + '
\n'; 'State: ' + $coordinates->find('state') + '
\n'; 'Zip: ' + $coordinates->find('zip') + '
\n'; /if;
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
define_tag( 'geocode', -namespace='tsp_', -required='address', -priority='replace', -description='Looks up the given address at geocoder.us.' ); local('url' = 'http://rpc.geocoder.us/service/csv'); local('getparams') = array( 'address' = #address ); local('response') = include_url( #url, -getparams=#getparams ); #response >> 'sorry' ? return; local('out' = map); local('fields') = array( 'latitude', 'longitude', 'street', 'city', 'state', 'zip' ); iterate(#response->split(','), local('i')); #out->insert(#fields->get(loop_count) = (loop_count < 3 ? decimal(#i) | #i)); /iterate; return(#out); /define_tag;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Thanks a bunch!