Lasso Soft Inc. > Home

[yahoo_geocode]

Linkyahoo_geocode
AuthorJason Huck
CategoryUtility
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted27 Mar 2006
Updated27 Mar 2006
More by this author...

Description

Geocodes the given address via Yahoo! Geocoding API. Requires a valid Yahoo! Application ID. Returns a map containing all of the address components, including longitude and latitude.

Sample Usage

yahoo_geocode(
	-appid='myAppId',
	-location='1815 Griffin Road, Dania Beach, FL  33004'
);

Source Code

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='yahoo_',
	-required='appid',
	-optional='street',
	-optional='city',
	-optional='state',
	-optional='zip',
	-type='integer',
	-optional='location',
	-priority='replace',
	-description='Geocodes the given address via Yahoo! Geocoding API.'
);
	local('getparams') = params;
	iterate(#getparams, local('i'));
		#i->first->removeleading('-');
	/iterate;

	local('response') = xml(
		string(
			include_url(
				'http://api.local.yahoo.com/MapsService/V1/geocode',
				-getparams=#getparams
			)
		)
	);
			
	local('out' = map);
	
	local('fields') = array(
		'Latitude',
		'Longitude',
		'Address',
		'City',
		'State',
		'Zip',
		'Country'
	);
	
	local('p') = string(#response->extract('//@precision')->first)->split('"')->second;
	#out->insert('Precision' = #p);
	
	iterate(#fields, local('f'));
		local('d') = #response->extract('//*[local-name()=\'' + #f + '\']/text()')->first;
		#out->insert(#f = #d);
	/iterate;
	
	return(#out);
/define_tag;

Related Tags

Comments

13 Apr 2006, Chris Corwin

hahahha

i just spent s few hours making this very thing.

oops.

*reminder* -- check here first.

13 Apr 2006, Dan McComb

Works great

I'm using this to grab the lat and long of new members on Biznik.com based on their zip code, and it works great. It even works with major cities if you pass only a city name, which is good for non-US addresses. Then, I can do really cool stuff with it like this map: http://www.biznik.com/maps/index.html

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft