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?
Identify will not return features that are not part of the definition expression on a layer.
One workaround you can try is to have another layer (same data source, no definition expression) but set the layer opacity to 0; since opacity will be ignored with identify... Identify features—ArcGIS Runtime SDK for .NET | ArcGIS for Developers, if you identify features on this new layer you will get the features you want.
In this case you will only see the features returned by the definition expression, but you can identify all the features.
Yup I was thinking the same. If they were offline I would say you could toggle the DefinitionExpression off/on. We do for some other things and it isn't noticeable to the user, for something doing a small search
Actually, oddly enough, I had to set the Opacity to 0.01 for this to work. If I set it to flat zero, the polygons still weren't being returned by the IdentifyLayerAsync function at the given point where the user clicked on the map.
The map is being smart and not doing work if the layer isn't actually visible. This means it's not actually pulling down data at all in this case. The idea behind identify is you're able to click what you see. If you can't see it, you can't click it.
The alternative is to do a spatial query against that layer instead if using identify.
Thank you for this suggestion. I already implemented the zero opacity fake layer, but now I'm starting to think your solution might be cleaner (or more efficient, at least).
I'm assuming that I would need to first somehow convert the currently clicked on map position (passed into the GeoTapped event as e.Position) into an actual MapPoint. I think I have the code to do that.
However, which function would I use to perform a spatial query to find out which polygons intersect the MapPoint?
The GeoTapped event also has e.Location which will give you the MapPoint ;)
How you query a layer depends on the layer type. If it's a feature layer, you'd get it's FeatureTable and use the QueryAsync method.