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

Description

Executes a query operation on a layer resource of a map service exposed by the ArcGIS Server REST API.

Class hierarchy

esri.tasks.QueryTask

Constructor

Constructor Description
esri.tasks.QueryTask(url) Creates a new QueryTask object used to execute a query on the layer resource identified by the url.

Properties

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

Methods

Method Return Value Description
execute(parameters, callback?, errback?) dojo.Deferred Executes a Query against an ArcGIS Server map layer. The result is returned as a FeatureSet. If the query is successful, the user-specified callback function is invoked with the result. A FeatureSet contains an array of Graphic features, which can be added to the map using Map.graphics.add(). This array will not be populated if no results are found.

Events

Event Description
onComplete(featureSet) This event is fired when the QueryTask.execute() method has completed. The result will be a FeatureSet. This is the same signature returned if the optional callback is specified.
onError(error) Fires when an error occurs when executing the task.
Constructor Detail

esri.tasks.QueryTask(url)

Creates a new QueryTask object used to execute a query on the layer resource identified by the url.
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.
Properties Detail

<String> url

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

execute(parameters, callback?, errback?)

Executes a Query against an ArcGIS Server map layer. The result is returned as a FeatureSet. If the query is successful, the user-specified callback function is invoked with the result. A FeatureSet contains an array of Graphic features, which can be added to the map using Map.graphics.add(). This array will not be populated if no results are found.

The return object of dojo.Deferred was added at v1.4.
Return value: dojo.Deferred
Input Parameters:
<Query> parameters Required Specifies the attributes and spatial filter of the query.
<Function> callback Optional The argument passed to the callback function, which is a FeatureSet.
<Function> errback Optional An error object is returned if an error occurs on the Server during task execution. (As of v1.3)
See also:
onComplete   onError  

Events Detail

onComplete(featureSet)

This event is fired when the QueryTask.execute() method has completed. The result will be a FeatureSet. This is the same signature returned if the optional callback is specified.
Arguments:
<FeatureSet> featureSet The results of a query operation performed on a layer.
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