Feature layer selection
Select features in a feature layer.
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.
Tap on a feature in the map. All features within a given tolerance (in pixels) of the tap will be selected.
- Create a
ServiceFeatureTablefrom a feature service URL.
- Create a
FeatureLayerfrom the service feature table.
- Identify nearby features at the tapped location using
IdentifyLayerAsync(featureLayer, clickLocation, tolerance, returnPopupsOnly, maxResults)on the map view.
- Select all identified features in the feature layer with
This sample uses the Gross Domestic Product, 1960-2016 feature service. Only the 2016 GDP values are shown.
features, layers, select, selection, tolerance
<?xml version="1.0" encoding="utf-8"?> <ContentPage 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" x:Class="ArcGISRuntime.Samples.FeatureLayerSelection.FeatureLayerSelection"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Label Text="Tap to select features." HorizontalTextAlignment="Center" /> <esriUI:MapView x:Name="MyMapView" Grid.Row="1" /> </Grid> </ContentPage>