Feature layer definition expression

View inWPFUWPFormsiOSAndroid
View on GitHub
Sample viewer app

Limit the features displayed on a map with a definition expression.

Image of feature layer definition expression

Use case

Set a definition expression to filter out the features to be displayed. You might filter a dataset of tree quality selecting for only those trees which require maintenance or are damaged.

How to use the sample

Press the 'Apply Expression' button to limit the features requested from the feature layer to those specified by the SQL query definition expression. Click the 'Reset Expression' button to remove the definition expression on the feature layer, which returns all the records.

How it works

  1. Create a service feature table from a URL.
  2. Create a feature layer from the service feature table.
  3. Set the limit of the features on your feature layer using the DefinitionExpression.

Relevant API

  • DefinitionExpression
  • FeatureLayer
  • ServiceFeatureTable

About the data

This map displays point features related to crime incidents that have been reported by city residents.

Tags

definition expression, filter, limit data, query, restrict data, SQL, where clause

Sample Code

FeatureLayerDefinitionExpression.xamlFeatureLayerDefinitionExpression.xaml.cs
                        
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.FeatureLayerDefinitionExpression.FeatureLayerDefinitionExpression"
    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}">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Button Content="Apply expression"
                        Grid.Column="0"
                        Margin="0,0,5,0"
                        Click="OnApplyExpressionClicked" />
                <Button Content="Reset expression"
                        Grid.Column="1"
                        Click="OnResetButtonClicked" />
            </Grid>
        </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.