I'm trying to use the IdentifyLayerAsync function to search for polygons in a layer that I currently have a DefinitionExpression in effect, and it's not returning the polygons that aren't currently visible because of the filter. Is there any way to get around this restriction?
I will research the QueryAsync. All my experience thus far has only been using the QueryFeaturesAsync method using WHERE clauses directed at Attribute values. This spatial query stuff will be some new fun for me! I'm hunting for examples now.
Thanks once again for your help.
Something along these lines. I always forget what the correct SpatialRelationship is should be either Within or Contains
private async Task<Feature> Query(Map map, MapPoint mapPoint)
{
FeatureLayer featureLayer = map.OperationalLayers.OfType<FeatureLayer>().First(fl => fl.Name == "MyLayerName");
var parameters = new QueryParameters {Geometry = mapPoint, SpatialRelationship = SpatialRelationship.Within};
var results = await featureLayer.FeatureTable.QueryFeaturesAsync(parameters);
return results.First();
}
Thanks Joe! This community is beyond helpful!
I have a follow-up question....
Although the QueryFeaturesAsync method you provided a wrapper function for works well and returns the feature that the given MapPoint is within, it isn't returning the feature with all the attributes populated (only the first two out of 27 are loaded). This is causing an error "The given key was not present in the dictionary" when I go to retrieve or update the values. I looked at all the QueryParameter properties, and I couldn't locate any that tell it to load all the attributes upon running the query. I tried the one that tells it to load the geometry, but that didn't solve the issue.
await feature.LoadAsync()
https://community.esri.com/thread/236680-get-attributes-from-featurelayergetselectedfeaturesasync
By design all attributes are not returned when a ServiceLayer is queried in order to reduce the data coming across the wire
That worked, thanks once again Joe!
-Steve