require(["esri/tasks/query"], function(Query) { /* code goes here */ });
Name | Summary |
---|---|
new Query() | Creates a new Query object used to execute a query on the layer resource identified by the URL. |
Name | Description |
---|---|
SPATIAL_REL_CONTAINS | Part or all of a feature from feature class 1 is contained within a feature from feature class 2. |
SPATIAL_REL_CROSSES | The feature from feature class 1 crosses a feature from feature class 2. |
SPATIAL_REL_ENVELOPEINTERSECTS | The envelope of feature class 1 intersects with the envelope of feature class 2. |
SPATIAL_REL_INDEXINTERSECTS | The envelope of the query feature class intersects the index entry for the target feature class. |
SPATIAL_REL_INTERSECTS | Part of a feature from feature class 1 is contained in a feature from feature class 2. |
SPATIAL_REL_OVERLAPS | Features from feature class 1 overlap features in feature class 2. |
SPATIAL_REL_RELATION | Allows specification of any relationship defined using the Shape Comparison Language. |
SPATIAL_REL_TOUCHES | The feature from feature class 1 touches the border of a feature from feature class 2. |
SPATIAL_REL_WITHIN | The feature from feature class 1 is completely enclosed by the feature from feature class 2. |
Name | Type | Summary |
---|---|---|
distance | Number | Buffer distance for input geometries. |
geometry | Geometry | The geometry to apply to the spatial filter. |
geometryPrecision | Number | Specify the number of decimal places for the geometries returned by the query operation. |
groupByFieldsForStatistics | String[] | One or more field names that will be used to group the statistics. |
maxAllowableOffset | Number | The maximum allowable offset used for generalizing geometries returned by the query operation. |
multipatchOption | String | Parameter to support querying feature services whose data source is a multipatch featureclass. |
num | Number | Number of features to retrieve. |
objectIds | Number[] | A comma delimited list of ObjectIds for the features in the layer/table that you want to query. |
orderByFields | String[] | One or more field names that will be used to order the query results. |
outFields | String[] | Attribute fields to include in the FeatureSet. |
outSpatialReference | SpatialReference | The spatial reference for the returned geometry. |
outStatistics | StatisticDefinition[] | The definitions for one or more field-based statistic to be calculated. |
pixelSize | Symbol | Specify the pixel level to be identified on the x and y axis. |
quantizationParameters | Object | Used to project the geometry onto a virtual grid, likely representing pixels on the screen.
Note:Quantization parameter only works with ArcGIS Online hosted services. See the object specifications table below for the structure of the quantizationParameters object. |
relationParam | String | The 'Shape Comparison Language' string to evaluate. |
returnDistinctValues | Boolean | If true then returns distinct values based on the fields specified in the outFields . |
returnGeometry | Boolean | If "true", each feature in the FeatureSet includes the geometry. |
spatialRelationship | String | The spatial relationship to be applied on the input geometry while performing the query. |
start | Number | Zero-based index indicating where to begin retrieving features. |
text | String | Shorthand for a where clause using "like". |
timeExtent | TimeExtent | Specify a time extent for the query. |
units | String | The unit for calculating the buffer distance. |
where | String | A where clause for the query. |
require([ "esri/tasks/query", ... ], function(Query, ... ) { var query = new Query(); ... });
Number
> distanceGeometry
> geometryfunction executeQueryTask(event) { // When the user clicks on a map, the onClick event returns the event point // where the user clicked. The event contains mapPoint (esri.geometry.Point) query.geometry = event.mapPoint; //Execute task queryTask.execute(query, showResults); }
Number
> geometryPrecisionquery.geometryPrecision = 1;
String[]
> groupByFieldsForStatisticsgroupByFieldsForStatistics
is only valid when outStatistics
have been defined. As of version 3.16, standard SQL expressions may also be used in place of field names when grouping by fields and querying hosted feature services for statistics. (Added at v2.6)query.groupByFieldsForStatistics = ["SUB_REGION"];
Number
> maxAllowableOffsetString
> multipatchOptionxyFootprint
function queryTaskExecuteCompleteHandler(queryResults){ console.log("complete", queryResults); } function queryTaskErrorHandler(queryError){ console.log("error", queryError.error.details); } var queryTask = new QueryTask("http://servername.fqdn.suffix/arcgis/rest/services/Hosted/pasadena/FeatureServer/0"); var query = new Query(); query.objectIds = [22]; query.multipatchOption = "xyFootprint"; query.outFields = ["*"]; query.returnGeometry = true; queryTask.on("complete", queryTaskExecuteCompleteHandler); queryTask.on("error", queryTaskErrorHandler); queryTask.execute(query);
Number
> numNumber[]
> objectIdsString[]
> orderByFieldsOne or more field names that will be used to order the query results. Specifiy ASC (ascending) or DESC (descending) after the field name to control the order. The default order is ASC. orderByFields
is only supported on dynamic layers and tables where supportsAdvancedQueries
is true. As of version 3.16, standard SQL expressions may also be used in place of field names when ordering by fields in statistic queries on hosted feature services.
query.orderByFields = ["STATE_NAME DESC"];
String[]
> outFieldsquery.outFields = ["NAME", "STATE_ABBR", "POP04"];
SpatialReference
> outSpatialReferenceStatisticDefinition[]
> outStatisticsThe definitions for one or more field-based statistic to be calculated. outStatistics
is only supported on layers/tables where supportsStatistics
is true. If outStatistics
is specified then only a subset of query parameters are supported. The supported parameters depends on the version of your service. See the ArcGIS REST API documentation for details on which query parameters are supported at each version.
require([ "esri/tasks/query", "esri/tasks/StatisticDefinition", ... ], function(Query, StatisticDefinition, ... ) { var query = new Query(); var statisticDefinition = new StatisticDefinition(); statisticDefinition.statisticType = "sum"; statisticDefinition.onStatisticField = "POP2000"; statisticDefinition.outStatisticFieldName = "TotalPop"; query.outStatistics = [statisticDefinition]; ... });
Symbol
> pixelSizeObject
> quantizationParametersquantizationParameters
>< > extent |
Required | An extent defining the quantization grid bounds.
Its SpatialReference matches the input geometry spatial reference if one is specified for the query.
Otherwise, the extent will be in the layer's spatial reference. |
< > mode |
Required | Available value: "view ". Geometry coordinates are optimized for viewing and displaying of data. |
< > originPosition |
Required | Available value: "upperLeft " or "lowerLeft ". Integer's coordinates will be returned relative to the
origin position defined by this property value. Default is upperLeft origin position. |
< > tolerance |
Required | The tolerance is the size of one pixel in the outSpatialReference units, this number is used to convert the coordinates to integers by building a grid with resolution matching the tolerance . Each coordinate is then snapped to one pixel on the grid. Consecutive coordinates snapped to the same pixel are removed for reducing the overall response size.
The tolerance is in the units of outSpatialReference . If
outSpatialReference is not specified, then tolerance
is assumed to be in the unit of the spatial reference of the layer. If the tolerance is not specified, the
maxAllowableOffset is used. If the tolerance and
maxAllowableOffset are not specified, a default 10,000 * 10,000 grid is used. |
var query = new Query(); query.quantizationParameters = { mode: "view", originPosition: "upperLeft", tolerance: 4820, extent: layer.fullExtent };
String
> relationParamThe 'Shape Comparison Language' string to evaluate. Examples of valid strings are:
RELATE(G1,G2,"FFFTTT***)
dim (g1.boundary,g2.boundary) = linear
dim (g1.exterior, g2.boundary)= linear
The string describes the spatial relationship to be tested when the spatial relationship is esriSpatialRelRelation The Shape Comparison Language EDN topic has additional details.
Boolean
> returnDistinctValuesoutFields
. This parameter applies only if supportsAdvancedQueries property of the layer is true. Requires ArcGIS Server 10.1 Service Pack 1 or later. (Added at v3.11)true | false
false
Boolean
> returnGeometrytrue | false
false
String
> spatialRelationshipSPATIAL_REL_INTERSECTS
require([ "esri/tasks/query", ... ], function(Query, ... ) { var query = new Query(); query.spatialRelationship = Query.SPATIAL_REL_CONTAINS; ... });
Number
> startString
> textquery.text = stateName;
TimeExtent
> timeExtentrequire([ "esri/layers/FeatureLayer", "esri/TimeExtent", "esri/tasks/query", ... ], function(FeatureLayer, TimeExtent, Query, ... ) { var layer = new FeatureLayer( ... ); var timeExtent = new TimeExtent( ... ); var timeQuery = new Query(); timeQuery.timeExtent = timeExtent; layer.queryFeatures(timeQuery,function(featureSet) {}); ... });
String
> units"feet" | "miles" | "nautical-miles" | "us-nautical-miles" | "meters" | "kilometers"
String
> wherequery.where = "NAME = '" + stateName + "'";Number query example.
query.where = "POP04 > " + population;