Identify layers

View inWPFWinUIUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Identify features in all layers in a map.

Image of Identify layers

Use case

IdentifyLayers allows users to click on a map, returning features at that location across multiple layers. Because some layer types have sublayers, the sample recursively counts results for sublayers within each layer.

How to use the sample

Tap to identify features. An alert will show all layers with features under the cursor, as well as a layer count.

How it works

  1. The tapped position is passed to MapView.IdentifyLayersAsync
  2. For each IdentifyLayerResult in the results, features are counted.
    • Note: there is one identify result per layer with matching features; if the feature count is 0, that means a sublayer contains the matching features.

Relevant API

  • IdentifyLayerResult
  • IdentifyLayerResult.LayerContent.Name
  • IdentifyLayerResult.SublayerResults
  • MapView.IdentifyLayersAsync

Additional information

The GeoView supports two methods of identify: IdentifyLayerAsync(), which identifies features within a specific layer and IdentifyLayersAsync(), which identifies features for all layers in the current view.

Tags

identify, recursion, recursive, sublayers

Sample Code

IdentifyLayers.xamlIdentifyLayers.xamlIdentifyLayers.xaml.cs
Use dark colors for code blocksCopy
             
1
2
3
4
5
6
7
8
9
10
11
12
13
<UserControl x:Class="ArcGISRuntime.WPF.Samples.IdentifyLayers.IdentifyLayers"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <Label HorizontalAlignment="Center"
                   Content="Tap to identify features in all layers."
                   FontWeight="SemiBold" />
        </Border>
    </Grid>
</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.