Zoom to features matching a query and count the features in the current visible extent.
Queries can be used to search for features in a feature table using text entry. This is helpful for finding a specific feature by name in a large feature table. A query can also be used to count features in an extent. This could be used to count the number of a traffic incidents in a particular region when working with an incident dataset for a larger area.
Use the picker to zoom to the extent of the state specified. Use the button to count the features in the current extent.
Querying by state abbreviation:
- A
QueryParameters
object is created with aWhereClause
. FeatureTable.QueryExtentAsync
is called with theQueryParameters
object to obtain the extent that contains all matching features.- The extent is converted to a
Viewpoint
, which is passed toMapView.SetViewpointAsync
.
Counting features in the current extent:
- The current visible extent is obtained from a call to
MapView.GetCurrentViewpoint(ViewpointType)
. - A
QueryParameters
object is created with the visible extent and a definedSpatialRelationship
(in this case 'intersects'). - The count of matching features is obtained from a call to
FeatureTable.QueryFeatureCountAsync
.
- FeatureTable.QueryExtentAsync
- FeatureTable.QueryFeatureCountAsync
- MapView.GetCurrentViewpoint(ViewpointType)
- QueryParameters
- QueryParameters.Geometry
- QueryParameters.SpatialRelationship
- QueryParameters.WhereClause
See the Medicare Hospital Spending per Patient, 2016 layer on ArcGIS Online.
Hospitals in blue/turquoise spend less than the national average. Red/salmon indicates higher spending relative to other hospitals, while gray is average.
count, feature layer, feature table, features, filter, number, query