Click or drag to resize
FeatureLayer Class
ArcGIS Feature Layer display data from either the (1) offline data sources of: ArcGISFeatureTable or ShapefileTable or (2) the online data source of ServiceFeatureTable.
Inheritance Hierarchy

Namespace: Esri.ArcGISRuntime.Layers
Assembly: Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 10.2.7.0 (10.2.7.1234)
Syntax
[ContentPropertyAttribute("FeatureTable")]
public sealed class FeatureLayer : Layer, 
	ICopyright, ILegendSupport

The FeatureLayer type exposes the following members.

Constructors
  NameDescription
Public methodFeatureLayer
Initializes a new instance of the FeatureLayer class.
Public methodFeatureLayer(Uri)
Initializes a new instance of the FeatureLayer class with a ServiceFeatureTable.
Public methodCode exampleFeatureLayer(FeatureTable)
Initializes a new instance of the FeatureLayer class.
Top
Methods
  NameDescription
Public methodCheckAccess
Determines whether the calling thread has access to this DispatcherObject.
(Inherited from DispatcherObject.)
Public methodClearSelection
Unselects all features in the layer
Public methodClearValue(DependencyProperty)
Clears the local value of a property. The property to be cleared is specified by a DependencyProperty identifier.
(Inherited from DependencyObject.)
Public methodClearValue(DependencyPropertyKey)
Clears the local value of a read-only property. The property to be cleared is specified by a DependencyPropertyKey.
(Inherited from DependencyObject.)
Public methodCoerceValue
Coerces the value of the specified dependency property. This is accomplished by invoking any CoerceValueCallback function specified in property metadata for the dependency property as it exists on the calling DependencyObject.
(Inherited from DependencyObject.)
Public methodEquals
Determines whether a provided DependencyObject is equivalent to the current DependencyObject.
(Inherited from DependencyObject.)
Protected methodFinalize
Finalizer to release FeatureLayer resources
(Overrides ObjectFinalize.)
Public methodGetHashCode
Gets a hash code for this DependencyObject.
(Inherited from DependencyObject.)
Public methodGetLocalValueEnumerator
Creates a specialized enumerator for determining which dependency properties have locally set values on this DependencyObject.
(Inherited from DependencyObject.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodGetValue
Returns the current effective value of a dependency property on this instance of a DependencyObject.
(Inherited from DependencyObject.)
Public methodCode exampleHitTestAsync(ViewBase, Point, Int32)
Performs a hittest against the layer using a System.Windows.Point.
Public methodCode exampleHitTestAsync(ViewBase, Rect, Int32)
Performs a hittest against the layer using a System.Windows.Rect.
Public methodCode exampleHitTestAsync(ViewBase, Point, Int32, CancellationToken)
Performs a hittest against the layer using a System.Windows.Point.
Public methodCode exampleHitTestAsync(ViewBase, Rect, Int32, CancellationToken)
Performs a hittest against the layer using a System.Windows.Rect.
Public methodCode exampleInitializeAsync
Loads the metadata for this layer based on the current configuration.
(Inherited from Layer.)
Public methodInvalidateProperty
Re-evaluates the effective value for the specified dependency property
(Inherited from DependencyObject.)
Public methodIsFeatureVisible
Checks the visibility of the GdbFeature with the specified object id
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnPropertyChanged(DependencyPropertyChangedEventArgs)
Invoked whenever the effective value of any dependency property on this DependencyObject has been updated. The specific dependency property that changed is reported in the event data.
(Inherited from DependencyObject.)
Protected methodOnPropertyChanged(String)
Notifies listeners that a property value has changed.
(Inherited from Layer.)
Public methodReadLocalValue
Returns the local value of a dependency property, if it exists.
(Inherited from DependencyObject.)
Public methodResetFeatureVisibility
Resets all features that have been hidden back to visible.
Public methodResetRenderer
Resets the FeatureLayer Renderer back to the default renderer provided by the FeatureTable
Public methodSelectFeatures
Selects features with the specified Row ID
Public methodSetCurrentValue
Sets the value of a dependency property without changing its value source.
(Inherited from DependencyObject.)
Public methodCode exampleSetFeatureVisibility
Sets the visibility of the GdbFeatures with the specified row IDs.
Protected methodSetLayerInitializationFailed
status must be failed - if not throw
(Inherited from Layer.)
Protected methodSetLayerStatus
Status cannot be failed or it will throw. To set Status to LayerStatus.Failed, call SetLayerInitializationFailed.
(Inherited from Layer.)
Public methodSetValue(DependencyProperty, Object)
Sets the local value of a dependency property, specified by its dependency property identifier.
(Inherited from DependencyObject.)
Public methodSetValue(DependencyPropertyKey, Object)
Sets the local value of a read-only dependency property, specified by the DependencyPropertyKey identifier of the dependency property.
(Inherited from DependencyObject.)
Protected methodShouldSerializeProperty
Returns a value that indicates whether serialization processes should serialize the value for the provided dependency property.
(Inherited from DependencyObject.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodUnselectFeatures
Unselects features with the specified Row ID
Public methodVerifyAccess
Enforces that the calling thread has access to this DispatcherObject.
(Inherited from DispatcherObject.)
Top
Fields
  NameDescription
Public fieldStatic memberDefinitionExpressionProperty
Identifies the DefinitionExpression Dependency Property
Public fieldStatic memberLabelingProperty
Identifies the Labeling dependency property.
Public fieldStatic memberRendererProperty
Identifies the Renderer Dependency Property
Public fieldStatic memberSelectionColorProperty
Identifies the SelectionColor Dependency Property
Top
Properties
  NameDescription
Public propertyDefaultSpatialReference
Gets the default spatial reference.
(Inherited from Layer.)
Public propertyDefinitionExpression
Gets or sets the definition expression which is a where clause.
Public propertyDependencyObjectType
Gets the DependencyObjectType that wraps the CLR type of this instance. 
(Inherited from DependencyObject.)
Public propertyDispatcher
Gets the Dispatcher this DispatcherObject is associated with.
(Inherited from DispatcherObject.)
Public propertyDisplayName
Gets or sets the display name.
(Inherited from Layer.)
Public propertyCode exampleFeatureTable
Gets the feature table associated with the Feature Layer.
Public propertyFullExtent
Gets the full extent of the layer in it's default spatial reference.
(Inherited from Layer.)
Public propertyID
Gets or sets an ID associated with this layer.
(Inherited from Layer.)
Public propertyInitializationException
Gets the initialization exception.
(Inherited from Layer.)
Public propertyIsSealed
Gets a value that indicates whether this instance is currently sealed (read-only).
(Inherited from DependencyObject.)
Public propertyIsVisible
Gets or sets the layer visibility.
(Inherited from Layer.)
Public propertyCode exampleLabeling
Gets or sets the LabelProperties which is used to enable labeling of a FeatureLayer.
Public propertyMaxScale
Gets or sets the maximum scale to display this layer at. A small number allows the map to display the layer when zooming further in.
(Inherited from Layer.)
Public propertyMinScale
Gets or sets the minimum scale to render this layer at. A large number allows the map to display the layer when zooming further out.
(Inherited from Layer.)
Public propertyOpacity
Gets or sets the opacity.
(Inherited from Layer.)
Public propertyRenderer
Gets or sets the renderer.
Public propertySelectedFeatureIDs
Gets the Object IDs of selected GeodatabaseFeatures.
Public propertySelectionColor
Gets or sets the color for selected graphics.
Public propertyShowLegend
Gets or sets a value indicating whether this layer should show in a legend
(Inherited from Layer.)
Public propertyStatus
The Layer's Status, indicating whether it is being/has been initialized, or initialization failed.
(Inherited from Layer.)
Top
Events
  NameDescription
Public eventLegendChanged
Occurs when the legend of the layer changed.
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from Layer.)
Top
Remarks

Local disk based FeatureLayers DO NOT re-project to match the Map's SpatialReference!

It is recommended to always set the SpatialReference for the Map when using a FeatureLayer based on a local disk based FeatureTable such as a ShapefileTable or a ArcGISFeatureTable. The reason is that the visual elements of the FeatureLayer may not display if the Shapefile or ArcGISFeatureTable are not based on the SpatialReference WKID of 3787 (aka. Web Mercator). By specifying the Map's SpatialReference to be exactly the same at the ShapefileTable or ArcGISFeatureTable, you will be assured that it displays visually in the Map.

If the FeatureLayer is based on an ArcGIS Server web ServiceFeatureTable, then re-projection of the data automatically occurs to match the SpatialReference of the Map.

Examples

Shows creating a FeatureLayer in XAML and via code-behind. The FeatureLayer.InitializeAsync Method is used to obtain metadata about the layer (i.e. ID and Copyright) using the Async/Task framework.

Adding a FeatureLayer to a map via XAML and code-behind.

XAML
<Window x:Class="FeatureLayerXamlAndCodeBehind.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="600" Width="800"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">

    <Grid>

        <!-- Create a simple renderer with a red, solid polygon fill. The outline of the polygon is black. -->
        <Grid.Resources>
            <esri:SimpleRenderer x:Key="mySimpleRenderer_Red">
                <esri:SimpleRenderer.Symbol>
                    <esri:SimpleFillSymbol Color="Red"  Style="Solid">
                        <esri:SimpleFillSymbol.Outline>
                            <esri:SimpleLineSymbol Color="Black" Width="1" Style="Solid"/>
                        </esri:SimpleFillSymbol.Outline>
                    </esri:SimpleFillSymbol>
                </esri:SimpleRenderer.Symbol>
            </esri:SimpleRenderer>
        </Grid.Resources>

        <StackPanel Orientation="Vertical">
            <StackPanel Orientation="Vertical">

                <!-- TextBlock to provide the instructions on how to use the sample code. It will be 
                populated with instructions in the code-behind when the application loads. -->
                <TextBlock Height="58" HorizontalAlignment="Left" Name="TextBlock1" VerticalAlignment="Top" 
                           Width="770" TextWrapping="Wrap"  Margin="10,2,0,0" />

            </StackPanel>
            <StackPanel Orientation="Vertical">

                <!-- Button to add an FeatureLayer via code-behind. -->
                <Button Content="Add another FeatureLayer (via code-behind) for the specified Url." 
                        x:Name="Button1" Click="Button1_Click" Width="780" HorizontalAlignment="Left"/>

            </StackPanel>
            <StackPanel Orientation="Horizontal">

                <!-- A MapView Control to display various GIS layers. -->
                <esri:MapView x:Name="MapView1" Width="400" Height="480" VerticalAlignment="Top" Margin="2,2,2,2">

                    <!-- A Map. -->
                    <esri:Map  x:Name="Map1" >

                        <!-- 
                        Add a FeatureLayer. Define the renderer for the polygons. Set the ServiceFeatureTable ServiceUri to 
                        public ArcGIS Server web service. Set the Where clause to restrict the data coming back to just a few states.
                        -->
                        <esri:FeatureLayer ID="TX_OK_AZ_NM" Renderer="{StaticResource mySimpleRenderer_Red}">
                            <esri:FeatureLayer.FeatureTable>
                                <esri:ServiceFeatureTable 
                                    ServiceUri="http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" 
                                    Where="STATE_ABBR = 'TX' OR STATE_ABBR = 'OK' OR STATE_ABBR = 'AZ' OR STATE_ABBR = 'NM'"/>
                            </esri:FeatureLayer.FeatureTable>
                        </esri:FeatureLayer>

                    </esri:Map>
                </esri:MapView>

                <StackPanel Orientation="Vertical">

                    <!-- TextBox to display information about the various layers in the Map. -->
                    <TextBox x:Name="TextBox1" TextWrapping="Wrap" Height="480" Width="370" Margin="2,2,2,2"/>

                </StackPanel>

            </StackPanel>
        </StackPanel>
    </Grid>

</Window>

SPECIAL NOTE: The XAML displayed above comes from a C# project. If you are a VB.NET developer, you will need to modify the text for the x:Class namespace from "FeatureLayerXamlAndCodeBehind.MainWindow" to be just "MainWindow".

namespace FeatureLayerXamlAndCodeBehind
{
    public partial class MainWindow : System.Windows.Window
    {
        public MainWindow()
        {
            // This call is required by the designer.
            InitializeComponent();

            // Add any initialization after the InitializeComponent() call.

            // Provide instructions on how to use the sample. 
            TextBlock1.Text = "When the application loads a FeatureLayer will " + 
                                      "automatically be added to the Map (it was specified in XAML). Click the Button to add another " + 
                                      "FeatureLayer to the Map (it will be added via code-behind). The ID  and copyright " + 
                                      "information of each layer will displayed in the TextBox.";

            // Set the initial extent of the Map to show features from both FeatureLayers.
            Esri.ArcGISRuntime.Geometry.SpatialReference mySpatialReference = new Esri.ArcGISRuntime.Geometry.SpatialReference(4269);
            Esri.ArcGISRuntime.Geometry.Geometry myGeometry = new Esri.ArcGISRuntime.Geometry.Envelope(-122.05, 23.17, -83.29, 52.24, mySpatialReference);
            MapView1.Map.InitialViewpoint = new Esri.ArcGISRuntime.Controls.Viewpoint(myGeometry);

            // Call our custom 'async' function to display information about the FeatureLayer that was added in XAML.
            Init();
        }

        public async void Init()
        {
            // This function will display information about the FeatureLayer that was added in XAML.

            // Get the FeatureLayer by it's index number.        
            Esri.ArcGISRuntime.Layers.FeatureLayer myFeatureLayer = (Esri.ArcGISRuntime.Layers.FeatureLayer)MapView1.Map.Layers[0];

            // Initialize the FeatureLayer which allows for obtain various Property information.
            await myFeatureLayer.InitializeAsync();

            // Get the ID of the FeatureLayer.
            string myID = myFeatureLayer.ID;

            // Create a StringBuilder object to hold information about the FeatureLayer.
            System.Text.StringBuilder myStringBuilder = new System.Text.StringBuilder();

            // Add the ID of the FeatureLayer to the StringBuilder.
            myStringBuilder.Append("The 1st FeatureLayer was added via XAML and it's ID is: " + myID + System.Environment.NewLine);

            // Get the ServiceFeatureTable from the FeatureLayer.
            Esri.ArcGISRuntime.Data.ServiceFeatureTable myServiceFeatureTable = (Esri.ArcGISRuntime.Data.ServiceFeatureTable)myFeatureLayer.FeatureTable;

            // Get the FeatureServiceLayerInfo from the ServiceFeatureTable
            Esri.ArcGISRuntime.ArcGISServices.FeatureServiceLayerInfo myFeatureServiceLayerInfo = myServiceFeatureTable.ServiceInfo;

            // Get the copyright information about the FeatureLayer and add to the StringBuilder.
            string myCopyright = myFeatureServiceLayerInfo.CopyrightText;
            myStringBuilder.Append(myCopyright + System.Environment.NewLine);

            // Display the results of the StringBuilder text to the user.
            TextBox1.Text = myStringBuilder.ToString();
        }

        private async void Button1_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            // This function will add an FeatureLayer to the Map via code behind.

            // Create a new Uri that point to an FeatureLayer. It is the same FeatureLayer that was added via XAML but we will select a different
            // set of features (show later).
            System.Uri myUri = new System.Uri("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");

            // Create a new ServiceFeatureTable and set it's ServiceUri and Where clause Properties.
            Esri.ArcGISRuntime.Data.ServiceFeatureTable myServiceFeatureTable = new Esri.ArcGISRuntime.Data.ServiceFeatureTable();
            myServiceFeatureTable.ServiceUri = myUri.ToString();
            myServiceFeatureTable.Where = "STATE_ABBR = 'ND' OR STATE_ABBR = 'SD' OR STATE_ABBR = 'MT' OR STATE_ABBR = 'WY'";

            // Create a new instance of an FeatureLayer and set it's Id and FeatureTable Properties.
            Esri.ArcGISRuntime.Layers.FeatureLayer myFeatureLayer = new Esri.ArcGISRuntime.Layers.FeatureLayer();
            myFeatureLayer.ID = "ND_SD_MT_WY";
            myFeatureLayer.FeatureTable = myServiceFeatureTable;

            // Define an outline Symbol for the Fills.
            Esri.ArcGISRuntime.Symbology.SimpleLineSymbol myBlackSolidOutline = new Esri.ArcGISRuntime.Symbology.SimpleLineSymbol();
            myBlackSolidOutline.Color = System.Windows.Media.Colors.Black;
            myBlackSolidOutline.Style = Esri.ArcGISRuntime.Symbology.SimpleLineStyle.Solid;
            myBlackSolidOutline.Width = 1;

            // Define a simple polygon fill symbol (solid, blue, with black outline).
            Esri.ArcGISRuntime.Symbology.SimpleFillSymbol mySimpleFillSymbol_Blue = new Esri.ArcGISRuntime.Symbology.SimpleFillSymbol();
            mySimpleFillSymbol_Blue.Color = System.Windows.Media.Colors.Blue;
            mySimpleFillSymbol_Blue.Outline = myBlackSolidOutline;
            mySimpleFillSymbol_Blue.Style = Esri.ArcGISRuntime.Symbology.SimpleFillStyle.Solid;

            // Create a SimpleRenderer to hold the SimpleFillSymbol.
            Esri.ArcGISRuntime.Symbology.SimpleRenderer myRenderer = new Esri.ArcGISRuntime.Symbology.SimpleRenderer();
            myRenderer.Symbol = mySimpleFillSymbol_Blue;

            // Apply the SimpleRenderer to the FeatureLayer.
            myFeatureLayer.Renderer = myRenderer;

            // Add the FeatureLayer to the Map.
            MapView1.Map.Layers.Add(myFeatureLayer);

            // Initialize the FeatureLayer which allows for obtain various Property information.
            await myFeatureLayer.InitializeAsync();

            // Get the ID of the FeatureLayer.
            string myID = myFeatureLayer.ID;

            // Create a StringBuilder object to hold information about the FeatureLayer.
            System.Text.StringBuilder myStringBuilder = new System.Text.StringBuilder();
            myStringBuilder.Append(TextBox1.Text + System.Environment.NewLine);
            myStringBuilder.Append(System.Environment.NewLine);

            // Add the ID of the FeatureLayer to the StringBuilder.
            myStringBuilder.Append("The 2nd FeatureLayer was added via code-behind and it's ID is: " + myID + System.Environment.NewLine);

            // Get the FeatureServiceLayerInfo from the ServiceFeatureTable.
            Esri.ArcGISRuntime.ArcGISServices.FeatureServiceLayerInfo myFeatureServiceLayerInfo = myServiceFeatureTable.ServiceInfo;

            // Get the copyright information about the FeatureLayer and add to the StringBuilder.
            string myCopyright = myFeatureServiceLayerInfo.CopyrightText;
            myStringBuilder.Append(myCopyright + System.Environment.NewLine);

            // Display the results of the StringBuilder text to the user.
            TextBox1.Text = myStringBuilder.ToString();
        }
    }
}
See Also
Supported Platforms
This type is supported on the following ArcGIS Runtime .NET SDK platforms:
Windows Desktop
Windows Phone
Windows Store
Additional Examples
Hyperlink to ExampleDescription
FeatureLayer_IdentifyDemonstrates performing and Identify on a FeatureLayer. The FeatureLayer.HitTestAsync method is used to select (and highlight) the feature a user clicks/taps on as well as display specific attributes for that feature.
FeatureLayer_LabelingDemonstrates labeling highway names in a FeatureLayer.
FeatureLayer_SelectFeaturesByRectangleDemonstrates selecting features in a FeatureLayer by dragging a rectangle across the map. Features are then highlighted in the FeatureLayer and their selected ID values are displayed in a Listbox.
FeatureLayer_SetFeatureVisibleDemonstrates being able to turn off the visibility of a feature in a FeatureLayer by tapping on it.
FeatureLayerViaGeodatabaseDemonstrates creating a FeatureLayer from a GeodatabaseFeatureTable in an ArcGIS Runtime provisioned Geodatabase that is stored locally on disk.
FeatureLayerViaGeodatabaseWebDownloadDemonstrates downloading a Geodatabase on ArcGIS Server to the local disk and then creating a FeatureLayer from a GeodatabaseFeatureTable in the downloaded Geodatabase.
FeatureLayerViaShapefileDemonstrates creating a FeatureLayer from a ShapefileTable that is stored locally on disk.
FeatureLayerXamlAndCodeBehindShows creating a FeatureLayer in XAML and via code-behind. The FeatureLayer.InitializeAsync Method is used to obtain metadata about the layer (i.e. ID and Copyright) using the Async/Task framework.
Mapview_LayerLoadedDemonstrates how to determine if a particular layer has loaded via the MapView.LayerLoaded Event.
MapView_LayersLoadedAsyncDemonstrates how to determine if a particular layer has loaded via the MapView.MapView_LayersLoadedAsync Method.
MapView_OverlaysDemonstrates displaying a UIElement on top of the MapView using the MapView.Overlays Property. This is useful for performing MapTip functionality.
MultipleMapsInMapViewDemonstrates switching out different Map objects (with different layers) for the MapView.Map Property.
PictureFillSymbolDemonstrates the using a SimpleRenderer with options for PictureFillSymbol.
PictureMarkerSymbolDemonstrates the using a SimpleRenderer with options for SimpleMarkerSymbol, PictureMarkerSymbol, and TextMarkerSymbol.