Link | google_geocode |
Author | Jason Huck |
Category | Utility |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 10 Jul 2006 |
Updated | 10 Jul 2006 |
More by this author... |
This tag returns a map of longitude and latitude for the given street address using the Google Maps API. Accepts two parameters: a valid API key and a street address. Requires [xml_tree].
google_geocode( -key='your_api_key_here', -address'your street address here' );
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='google_', -req='key', -req='address', -copy, -priority='replace', -description='Geocodes the given address via Google.' ); local('out' = map); local('codes') = map( 200 = 'G_GEO_SUCCESS', 601 = 'G_GEO_MISSING_ADDRESS', 602 = 'G_GEO_UNKNOWN_ADDRESS', 603 = 'G_GEO_UNAVAILABLE_ADDRESS', 610 = 'G_GEO_BAD_KEY', 620 = 'G_GEO_TOO_MANY_QUERIES', 500 = 'G_GEO_SERVER_ERROR' ); local('getparams') = array( 'q' = #address, 'output' = 'xml', 'key' = #key ); protect; local('data') = xml_tree( include_url( 'http://maps.google.com/maps/geo', -getparams=#getparams ) ); local('code') = integer(#data->response->status->code->contents); if(#code == 200); local('coords') = #data->response->placemark->point->coordinates->contents; #out->insert('longitude' = decimal(@#coords->split(',')->first)); #out->insert('latitude' = decimal(@#coords->split(',')->second)); return(#out); else; return(#codes->find(#code)); /if; handle_error; return('Unknown error.'); /handle_error; /protect; /define_tag;
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
If "placemark" is an array, you get an error