Feature layer selection

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Select features in a feature layer.

Image of feature layer selection

Use case

Selecting features, whether by query or identify, can be an important step both in editing data and visualizing results. One possible use case would be to query a feature layer containing street furniture. A query might look for type "bench" and return a list of bench features contained in the features with an attribute of type bench. These might be selected for further editing (see FeatureQueryResult) or may just be highlighted visually.

How to use the sample

Click on a feature in the map. All features within a given tolerance (in pixels) of the click will be selected.

How it works

  1. Create a ServiceFeatureTable from a feature service URL.
  2. Create a FeatureLayer from the service feature table.
  3. Identify nearby features at the clicked location using IdentifyLayerAsync(featureLayer, clickLocation, tolerance, returnPopupsOnly, maxResults) on the map view.
  4. Select all identified features in the feature layer with SelectFeatures(features).

Relevant API

  • Feature
  • FeatureLayer
  • ServiceFeatureTable

About the data

This sample uses the Gross Domestic Product, 1960-2016 feature service. Only the 2016 GDP values are shown.

Tags

features, layers, select, selection, tolerance

Sample Code

FeatureLayerSelection.xamlFeatureLayerSelection.xamlFeatureLayerSelection.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<UserControl
    x:Class="ArcGISRuntime.UWP.Samples.FeatureLayerSelection.FeatureLayerSelection"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">
    <Grid>
        <esriUI:MapView x:Name="MyMapView" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock Text="Tap to select features."
                       TextAlignment="Center"
                       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.