private async Task QueryStateFeature(string stateName)
{
try
{
// Create a query parameters that will be used to Query the feature table
QueryParameters queryParams = new QueryParameters();
// Construct and assign the where clause that will be used to query the feature table
queryParams.WhereClause = "upper(STATE_NAME) LIKE '%" + (stateName.ToUpper()) + "%'";
// Query the feature table
FeatureQueryResult queryResult = await _featureTable.QueryFeaturesAsync(queryParams);
// Cast the QueryResult to a List so the results can be interrogated
var features = queryResult.ToList();
if (features.Any())
{
// Get the first feature returned in the Query result
Feature feature = features[0];
// Add the returned feature to the collection of currently selected features
_featureLayer.SelectFeature(feature);
// Zoom to the extent of the newly selected feature
await myMapView.SetViewpointGeometryAsync(feature.Geometry.Extent);
}
else
{
MessageBox.Show("State Not Found!", "Add a valid state name.");
}
}
catch (Exception ex)
{
MessageBox.Show("Sample error", "An error occurred" + ex.ToString());
}
}
}