IdentifyLayerAsync not returning polygons hidden by DefinitionExpression...

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

Is this online or offline data?

Thanks,
-Joe
0 Kudos
StevenMcKenna1
New Contributor

It's online connected to our local portal server. I'm using the .NET Runtime.

Thanks!

0 Kudos
TonyWakim
Esri Contributor

Steven,

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.

Tony

StevenMcKenna1
New Contributor

Why thank you Tony. That is a wonderfully sneaky idea!  I'm going to implement this.

Thanks again!

0 Kudos
JoeHershman
MVP Regular Contributor

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

Thanks,
-Joe
0 Kudos
StevenMcKenna
New Contributor II

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.

0 Kudos
dotMorten_esri
Esri Notable Contributor

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.

StevenMcKenna
New Contributor II

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?

0 Kudos
dotMorten_esri
Esri Notable Contributor

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.