require(["esri/tasks/QueryTask"], function(QueryTask) { /* code goes here */ });Description
(Added at v1.0)
Executes a query operation on a layer resource of a map service exposed by the ArcGIS Server REST API.
SamplesSearch for
samplesthat use this class.
Constructors Properties Methods execute(parameters, callback?, errback?)Deferred
Executes a Query against an ArcGIS Server map layer. executeForCount(query, callback?, errback?) Deferred
Get a count of the number of features that satisfy the input query. executeForExtent(query, callback?, errback?) Deferred
Get the extent of the features that satisfy the input query. executeForIds(parameters, callback?, errback?) Deferred
Executes a Query against an ArcGIS Server map layer. executeRelationshipQuery(parameters, callback?, errback?) Deferred
Executes a RelationshipQuery against an ArcGIS Server map layer (or table). 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.
Constructor Details
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 https://www.example.com/argis/rest/services/Portland/Portland_ESRI_LandBase_AGO/MapServer/1. <Object
> options Optional Optional parameters. See options list. options
properties: <String
> gdbVersion Optional The geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater <LayerSource
> source Optional The dynamic layer or table source. The url should end with /dynamicLayer
. Sample:
require([ "esri/tasks/QueryTask", ... ], function(QueryTask, ... ) { var queryTask = new QueryTask("https://www.example.com/argis/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer/0"); ... });
Property Details
The geodatabase version to display. (As of v2.7). Requires ArcGIS Server service 10.1 or greater (Added at v2.7)
The dynamic layer or table source. The url should end with /dynamicLayer
.
URL to the ArcGIS Server REST resource that represents a map service layer. To obtain the URL, use
Services Directory.
Method Details
Executes a
Queryagainst 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
FeatureSetcontains an array of
Graphicfeatures, which can be added to the map using
Map.graphics.add(). This array will not be populated if no results are found.
Parameters: <Query
> parameters Required Specifies the attributes and spatial filter of the query. <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:
require([ "esri/tasks/query", "esri/tasks/QueryTask", ... ], function(Query, QueryTask, ... ) { var query = new Query(); var queryTask = new QueryTask( ... ); query.where = "STATE_NAME = 'Washington'"; query.outSpatialReference = {wkid:102100}; query.returnGeometry = true; query.outFields = ["CITY_NAME"]; queryTask.execute(query, addPointsToMap); ... });
Get a count of the number of features that satisfy the input query. Valid only for layers published using ArcGIS Server 10 SP1 or greater. Layers published with earlier versions of ArcGIS Server return an error to the error callback. (Added at v2.1)
Parameters: <Query
> query Required Specify the input query object. <Function
> callback Optional The function to call when the method has completed. The arguments in the function are the same as the execute-for-count-complete event. <Function
> errback Optional An error object is returned if an error occurs on the Server during task execution. Sample:
require([ "esri/tasks/query", "esri/tasks/QueryTask", "dojo/dom"... ], function(Query, QueryTask, dom, ... ) { var query = new Query(); var queryTask = new QueryTask( ... ); query.where = "POP90_SQMI < 100"; queryTask.executeForCount(query,function(count){ dom.byId("info").innerHTML = count + " features matched the input query"; },function(error){ console.log(error); }); ... });
Get the extent of the features that satisfy the input query. The count of features that satisfy the input query is returned as well. Valid only for
hosted features serviceson
arcgis.comand for ArcGIS Server 10.3.1 and later.
(Added at v3.9) Parameters: <Query
> query Required Specify the input query object. <Function
> callback Optional The function to call when the method has completed. The arguments in the function are the same as the execute-for-extent-complete event. <Function
> errback Optional An error object is returned if an error occurs on the Server during task execution.
Executes a
Queryagainst an ArcGIS Server map layer. The result is an array of object IDs for features that satisfy the input query. There is no limit to the number of object IDs returned in the ID array response.
(Added at v2.0) Parameters: <Query
> parameters Required Specifies the attributes and spatial filter of the query. <Function
> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onExecuteForIdsComplete event. <Function
> errback Optional An error object is returned if an error occurs on the Server during task execution. Sample:
require([ "esri/tasks/query", "esri/tasks/QueryTask", ... ], function(Query, QueryTask, ... ) { var query = new Query(); var queryTask = new QueryTask( ... ); query.where = "region = 'Southern California'"; queryTask.executeForIds(query,function(results){ console.log(results); }); ... });
Executes a
RelationshipQueryagainst an ArcGIS Server map layer (or table). The result is returned as a
FeatureSet. If the query is successful, the user-specified callback function is invoked with the result. The result of this operation are featuresets grouped by source layer (or table) object IDs. Each featureset contains an array of
Graphicfeatures including the values for the fields requested by the user. This array will not be populated if no results are found.
(Added at v2.0) Parameters: <RelationshipQuery
> parameters Required Specifies the attributes and spatial filter of the query. <Function
> callback Optional The function to call when the method has completed. The arguments in the function are the same as the onExecuteRelationshipQueryComplete event. <Function
> errback Optional An error object is returned if an error occurs on the Server during task execution.
Event Details
[ On Style Events | Connect Style Event ]
Fires when the query operation is complete. Should be used in favor of onComplete. (Added at v3.5)
Event Object Properties: <FeatureSet
> featureSet Fires when the query operation is complete.
Fires when an error occurs when executing the task. (Added at v3.6)
Fires when the query for the count is complete. This event is only available for layers published using ArcGIS Server 10 SP1 or later. Should be used in favor of onExecuteForCountComplete. (Added at v3.5)
Event Object Properties: <Number
> count Fires when the query for the count is complete. This event is only available for layers published using ArcGIS Server 10 SP1 or later. Event Object Properties: <Number
> count Number of the features that satisfy the input query. <Object
> extent Extent of the features that satisfy the input query. At v3.10, the type will be Extent
.
Fires when the query on IDs is complete. Should be used in favor of onExecuteForIdsComplete. (Added at v3.5)
Event Object Properties: <Number[]
> objectIds Fires when the query on IDs is complete.
Fires when the executeRelationshipQuery is complete. Should be used in favor of onExecuteRelationshipQueryComplete. (Added at v3.5)
Event Object Properties: <FeatureSet[]
> featureSets Fires when the executeRelationshipQuery
is complete.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4