[yahoo_geocode]

Description

Link: [yahoo_geocode]
Author: Jason Huck
Category: Utility
Version: 8.x
License:
Posted: Mar. 27, 2006
Updated: Mar. 27, 2006
More by this author...
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.

Parameters

-appid string, required A valid Yahoo! Application ID.
-street string, optional The street address.
-city string, optional The city.
-state string, optional The state/province.
-zip integer, optional The zip/postal code.
-location string, optional Complete or partial address, can be used instead of the other, separate parameters.

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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

04/13/2006, Chris Corwin
hahahha
i just spent s few hours making this very thing. oops. *reminder* -- check here first.
04/13/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
Email:


Password:



Newest

Most Popular