IdentifyLayerAsync not returning polygons hidden by DefinitionExpression...

1695
15
03-03-2020 09:50 AM
StevenMcKenna1
New Contributor

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?

Tags (1)
0 Kudos
15 Replies
StevenMcKenna
New Contributor II

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.

0 Kudos
JoeHershman
MVP Regular Contributor

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
StevenMcKenna
New Contributor II

Thanks Joe! This community is beyond helpful!

StevenMcKenna
New Contributor II

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.

0 Kudos
JoeHershman
MVP Regular Contributor
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

Thanks,
-Joe
StevenMcKenna
New Contributor II

That worked, thanks once again Joe!

-Steve

0 Kudos