Parameters:
nFinder - the number of a given finder
For the USA map you can use the following constants:
ADDRESS = 0
INTERSECTION = 1
ZIP = 2
CITY = 3
COUNTY = 4
AREACODE = 5
COORDINATES = 6
Additional parameters depend on the amount and order of the fields of the specified finder.
For example, the ADDRESS finder has the following fields (the order of the fields is important):
'Address', 'ZIP', 'City', 'State'. Therefore, if you want to find an address you
must use the following syntax:
findLocation( ADDRESS, "380 New York St", "92373", "Redlands", "CA");
Note that you can omit the city and state fields you don't want to enter them (or use city and state, if you do not have the ZIP Code):
findLocation( ADDRESS, "380 New York St", "92373") equals findLocation( ADDRESS, "380 New York St", "92373", "", "")
Other examples:
findLocation( CITY, "Redlands", "CA");
findLocation( CITY, "Redlands"); (results equal Redlands, CA and Redlands, CO)
findLocation( COUNTY, "Orange", "CA");
findLocation( INTERSECTION, "New York St", "W Park Ave", "", "Redlands", "CA")
Returns:
An array of the FoundLocation objects, or null if the location is not found (see the FoundLocation object)
// Finders (USA map) var ADDRESS = 0; var INTERSECTION = 1; var ZIP = 2; var CITY = 3; var COUNTY = 4; var AREACODE = 5; var COORDINATES = 6; // Finders (North American map) var NA_US_ADDRESS = 0; var NA_CA_ADDRESS = 1; var NA_US_INTERSECTION = 2; var NA_CA_INTERSECTION = 3; var NA_US_ZIP = 4; var NA_US_ZIP3 = 5; var NA_CA_POSTALCODE = 6; var NA_US_CITY = 7; var NA_CA_CITY = 8; var NA_US_COUNTY = 9; var NA_AREACODE = 10; var NA_COORDINATES = 11; function findLocation( nFinder) { var args = findLocation.arguments; if( args.length < 2) return null; var Finders = Map.getFinders(); var Finder = Finders.getFinder( nFinder); for(var i=0; i < Finder.getFieldCount(); i++) { var fValue = (i+1)>=args.length ? "" : args[i+1]; Finder.setFieldValue(i, fValue); } var rs = Finder.find(); if( isRSEmpty( rs)) return null; var Locations = new Array(); var i = 0; rs.moveFirst(); do { Locations[i++]=new FoundLocation( rs.getAsIntByName("SCORE"), rs.getAsStringByName( "NAME"), rs.getAsDoubleByName( "X"), rs.getAsDoubleByName( "Y"), rs.getAsDoubleByName( "LAT"), rs.getAsDoubleByName( "LONG") ); } while( rs.moveNext()) return Locations; } function isRSEmpty(rs) { return rs == null || rs.getRecordsCount() == 0; } function FoundLocation( score, label, x, y, lat, lon) { this.score = score; this.label = label; this.x = x; this.y = y; this.lat = lat; this.lon = lon; }