dojo.require("esri.tasks.query")esri.tasks.Query
| Constructor | Description |
|---|---|
| esri.tasks.Query() | Creates a new Query object used to execute a query on the layer resource identified by the URL. |
| Property | Type | Description |
|---|---|---|
| geometry | Geometry |
The geometry to apply to the spatial filter. The spatial relationship as specified by spatialRelationship is applied to this geometry while performing the query. The valid geometry types are Extent, Point, Multipoint, Polyline, or Polygon. |
| maxAllowableOffset | Number | The maximum allowable offset used for generalizing geometries returned by the query operation. The offset is in the units of the spatialReference. If a spatialReference is not defined the spatial reference of the map is used. |
| objectIds | Number[] | A comma delimited list of ObjectIds for the features in the layer/table that you want to query. |
| outFields | String[] |
Attribute fields to include in the FeatureSet. Fields must exist in the map layer. You must list the actual field names rather than the alias names. Returned fields are also the actual field names. However, you are able to use the alias names when you display the results. You can set field alias names in the map document. When you specify the output fields, you should limit the fields to only those you expect to use in the query or the results. The fewer fields you include, the faster the response will be. Each query must have access to the Shape and Objectid fields for a layer, but your list of fields does not need to include these two fields. |
| outSpatialReference | SpatialReference | The spatial reference for the returned geometry. If not specified, the geometry is returned in the spatial reference of the map. See Projected Coordinate Systems and Geographic Coordinate Systems for the list of supported spatial references. |
| relationParam | String | The 'Shape Comparison Language' string to evaluate. |
| returnGeometry | Boolean | If "true", each feature in the FeatureSet includes the geometry. Set to "false" (default) if you do not plan to include highlighted features on a map since the geometry makes up a significant portion of the response. |
| spatialRelationship | String | The spatial relationship to be applied on the input geometry while performing the query. The valid values are listed in the Constants table. |
| text | String | Shorthand for a where clause using "like". The field used is the display field defined in the map document. You can determine what the display field is for a layer in Services Directory. |
| timeExtent | TimeExtent | Specify a time extent for the query. |
| where | String | A where clause for the query. Any legal SQL where clause operating on the fields in the layer is allowed. |
| Constant | 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 |
var query = new esri.tasks.Query();
function 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);
}
query.outFields = ["NAME", "STATE_ABBR", "POP04"];
The '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.
var myQuery = new esri.tasks.Query(); myQuery.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
query.text = stateName;
var timeQuery = new esri.tasks.Query();
timeQuery.timeExtent = timeExtent;
layer.queryFeatures(timeQuery,function(featureSet) {});
query.where = "NAME = '" + stateName + "'";Number query example.
query.where = "POP04 > " + population;