require(["esri/tasks/FindTask"], function(FindTask) { /* code goes here */ });
Description
(Added at v1.0)
Search a map service exposed by the ArcGIS Server REST API based on a string value. The search can be conducted on a single field of a single layer, on many fields of a layer, or on many fields of many layers.
Samples
Search for
samples that use this class.
Constructors
Properties
url | String | URL to the ArcGIS Server REST resource that represents a map service. |
Methods
Events
[ On Style Events | Connect Style Event ]
All On Style event listeners receive a single event object. Additionally, the event object also contains a 'target' property whose value is the object which fired the event.
Events
complete | {
results: <FindResult[] >
} | Fires when the find operation is complete. |
error | {
error: <Error >
} | Fires when an error occurs when executing the task. |
Constructor Details
Creates a new FindTask object. A URL is a required parameter.
Parameters:
<String > url |
Required |
URL to the ArcGIS Server REST resource that represents a map service. An example is
https://www.example.com/argis/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer. |
<Object > options |
Optional |
Optional parameters. See options list. |
options
properties:
<String > gdbVersion |
Optional |
Specify the geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater |
Sample:
require([
"esri/tasks/FindTask", "esri/tasks/FindParameters", "dojo/dom", ...
], function(FindTask, FindParameters, dom, ... ) {
var find = new FindTask("https://www.example.com/argis/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/");
var params = new FindParameters();
params.layerIds = [2];
params.searchFields = ["STATE_NAME","STATE_FIPS"];
params.searchText = dom.byId("searchText").value;
find.execute(params, showResults);
...
});
Property Details
URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use
Services Directory.
Method Details
Sends a request to the ArcGIS REST map service resource to perform a search based on the
FindParameters specified in the findParameters argument. On completion, the onComplete event is fired and the optional callback function is invoked.
Parameters:
<FindParameters > findParameters |
Required |
Specifies the layers and fields that are used to search against. |
<Function > callback |
Optional |
The function to call when the method has completed. The arguments in the function are the same as the onComplete event. |
<Function > errback |
Optional |
An error object is returned if an error occurs on the Server during task execution. (As of v1.3) |
Sample:
findTask.execute(findParams, showResults);
Event Details
[ On Style Events | Connect Style Event ]
Fires when the find operation is complete. The result is an object with a results property containing an array of
FindResult. This is the same signature that is returned if the optional callback were specified. Should be used in favor of onComplete
(Added at v3.5) Event Object Properties:
<FindResult[] > results |
Provides information about a "find result". |
Fires when an error occurs when executing the task. (Added at v3.6)
Fires when the find operation is complete. The result is an array of
FindResult. This is the same signature that is returned if the optional callback were specified.
Event Object Properties:
<FindResult[] > findResults |
Provides information about a "find result". |
Fires when an error occurs when executing the task. (Added at v1.3)