[tsp_geocode]

Description

Link: [tsp_geocode]
Author: Jason Huck
Category: Utility
Version: 8.x
License: Public Domain
Posted: Feb. 08, 2006
Updated: Feb. 21, 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.

Parameters

-address string, required The address to look up.

Sample Usage

var('address') = '1815 Griffin Road, Dania Beach, FL  33004';
var('coordinates') = tsp_geocode($address);

if($coordinates->size);
	'Latitude: ' + $coordinates->find('latitude') + '<br>\n';
	'Longitude: ' + $coordinates->find('longitude') + '<br>\n';
	'Street: ' + $coordinates->find('street') + '<br>\n';
	'City: ' + $coordinates->find('city') + '<br>\n';
	'State: ' + $coordinates->find('state') + '<br>\n';
	'Zip: ' + $coordinates->find('zip') + '<br>\n';
/if;
						

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
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;

 

Related Tags



Comments

06/14/2006, Israel Thompson
Thanks a bunch!
This Tag has come in really handy! I've managed to plug it into a database and retrieve the coordinates for multiple coordinates along with search for single coordinates and display a map with a marker and info window. I have a question for you Jason. Are you going to create a Tag for the new Google geocoder? If so, I can't wait! When they released the new Google geocoder I realized more of my addresses were coming back as "found" rather than "not found" which is what I was getting sometimes with the one used by your tag, so I'm really interested if you are going to make a tag for the Google one! :) Thanks, Israel
Email:


Password:



Newest

Most Popular