On this page
The scripted locator profile provides a mechanism to perform a search against other layers and tables, and to present the results in the Find panel.
Profile variables
Variable name | Type | Description |
---|---|---|
$map | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. This can then be queried. |
$userId | Text | The unique user ID of the editor who is logged into the application. |
$userName | Text | The full name of the editor who is logged into the application. |
$userIdentity | Text | Provides a credential instance. This can be used when accessing external layers with the FeatureLayer function. The credentials represent the user’s logged in credentials. |
$session | Dictionary | A dictionary containing key value pairs. The dictionary contains all the session variables that have been configured in the app. When the application first launches, the user will be asked for values for the session variables. They can also (if configured) change session variables in the application. This provides programmatic access to the user’s choices / settings. |
$searchText | Text | The text to search for. |
$selection | FeatureSetCollection | The list of layers in the web map. Can be used with the FeatureSetByName or FeatureSetById function to get a particular layer in the map. It will only contain the features from each layer selected on the map. This can then be queried. |
$currentMapExtent | Extent | The current map extent. This value is not available for all scripts. |
$currentTool | Text | The type of tool selected. Will be one of new , add , effects , reshape , subtract , pan , select , unprotect . This value is not available for all scripts. It also represents the current state, not the state for why the script is running. |
Return types
The script should return a FeatureSet with geometry and a title and subtitle fields to show to the end user, so they can pick their favoured result.
Example
Search a table and append a geometry from another layer:
/** Search a table and use the geometry from another layer to find locations on
* the map.
*
* In this script an input search is matched against a lookup table which
* has no geometry information. Matches are then compared against service
* with geometry information based on a common key (e.g. TitleDeed number).
*
* @returns - The script must return a FeatureSet with geometry information.
*
*/
// Reference the Lookup Table
var searchTable = FeatureSetByName($map, "<TABLE>");
// Layer without lookup Field, but has Geometry
var layerWithGeometry = FeatureSetByName($map, "<LAYER>");
// Get the Search Text
var search = $searchText;
// Find the matched records, based on a SQL query
var matchedrecords = Filter(searchTable, "TITLE_DEED_NO=@search");
function addGeometry(feat) {
return Geometry(
First(Filter(layerWithGeometry, "DEED_ID=" + feat.Deed_ID))
);
}
//return a new FeatureSet with geometry.
return changeShape(matchedrecords, addGeometry, true, "polygon");