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

Tap on a feature in the map. All features within a given tolerance (in pixels) of the tap 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 tapped 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
15
<?xml version="1.0" encoding="utf-8" ?>

<ContentPage x:Class="ArcGISRuntime.Samples.FeatureLayerSelection.FeatureLayerSelection"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Label HorizontalTextAlignment="Center" Text="Tap to select features." />
        <esriUI:MapView x:Name="MyMapView" Grid.Row="1" />
    </Grid>
</ContentPage>

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