Identifying features in layers when users tap on map, but when layers not visible?

1030
2
Jump to solution
03-15-2021 03:20 PM
MichaelHorii
New Contributor II

Hi, I'd like to use the AGSMapView method identifyLayers() to determine what features are at a user-tapped map location. However, I noticed that only visible layers (whose isVisible property are set to true) return features.

Is this the expected behavior?  In my case, I'd like to use identifyLayers() to get features from "invisible" layers (whose isVisible property are set to false), but the closest I can get to this behavior is to set all layers visible, and reset the layer renderers and disable layer labels. Unfortunately, resetting the layer renderers and disabling the layer labels doesn't hide the intrinsic layer features, so the layers are visible.

Is there a way to use identifyLayers() to get features for map layers that aren't visible?

0 Kudos
1 Solution

Accepted Solutions
Nicholas-Furness
Esri Regular Contributor

Hi.

Identify is deliberately meant to be a user-driven operation, hence it works with visible layers.

However, you might be able to get the effect you want by setting the opacity of each "invisible" layer to 0, set the isVisible property to true, perform the identify, and then revert the opacity back to 1.0 and the isVisible to false. The layer will technically be visible, but you won't be able to see it. You might need to set the opacity to something very small (e.g. 0.001) but I think 0 will work.

The other way to do this is to make queries against each individual layer's featureTable (that's what Identify does behind the scenes) and synchronize the responses with a DispatchGroup.

Let me know if the opacity trick works.

View solution in original post

0 Kudos
2 Replies
Nicholas-Furness
Esri Regular Contributor

Hi.

Identify is deliberately meant to be a user-driven operation, hence it works with visible layers.

However, you might be able to get the effect you want by setting the opacity of each "invisible" layer to 0, set the isVisible property to true, perform the identify, and then revert the opacity back to 1.0 and the isVisible to false. The layer will technically be visible, but you won't be able to see it. You might need to set the opacity to something very small (e.g. 0.001) but I think 0 will work.

The other way to do this is to make queries against each individual layer's featureTable (that's what Identify does behind the scenes) and synchronize the responses with a DispatchGroup.

Let me know if the opacity trick works.

0 Kudos
MichaelHorii
New Contributor II

Great, thank you! The opacity trick works like a charm.

0 Kudos