Class: FindTaskE-mail This Topic Printable Version Give Us Feedback

Description

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.

Class hierarchy

esri.tasks.FindTask

Constructor

Constructor Description
esri.tasks.FindTask(url) Creates a new FindTask object. A URL is a required parameter.

Properties

Property Type Description
url String URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory.

Methods

Method Return Value Description
execute(findParameters, callback?, errback?) dojo.Deferred 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.

Events

Event Description
onComplete(findResults) 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.
onError(error) Fires when an error occurs when executing the task.
Constructor Detail

esri.tasks.FindTask(url)

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 layer in a service. An example is http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer/1. For more information on constructing a URL, see The Services Directory and the REST API.
Code snippets:
function init() {
  find = new esri.tasks.FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/");
  params = new esri.tasks.FindParameters();
  params.layerIds = [2];
  params.searchFields = ["STATE_NAME","STATE_FIPS"];
}
function doFind() {
  params.searchText = dojo.byId("searchText").value;
  find.execute(params, showResults);
}
Properties Detail

<String> url

URL to the ArcGIS Server REST resource that represents a map service. To obtain the URL, use Services Directory.
Methods Detail

execute(findParameters, callback?, errback?)

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.

The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input 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)
Code snippets:
 findTask.execute(findParams, showResults);

See also:
onComplete   onError  

Events Detail

onComplete(findResults)

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.
Arguments:
<FindResult[]> findResults Provides information about a "find result".
See also:
execute  

onError(error)

Fires when an error occurs when executing the task. (As of v1.3)
Arguments:
<Error> error ArcGIS Server error message returned in a JavaScript error object.
See also:
execute