Skip To Content ArcGIS for Developers Sign In Dashboard

FeatureLayer QML Type

A layer that can display features from a FeatureTable on a map. More...

Import Statement: import Esri.ArcGISRuntime 100.9
Since: Esri.ArcGISRuntime 100.0
Inherits:

Layer

Inherited By:

SubtypeFeatureLayer

Properties

Signals

Methods

Detailed Description

Feature layers display data from feature services or supported local data sources, including shapefiles, GeoPackages, and geodatabases. Feature layers can be used to display, select, and query features in a layer. If the underlying feature service or table supports editing, you can use it with a feature layer as a basis for editing geometry, attributes, and attachments. Feature layers are used to store features associated with a utility network.

In a MVC architecture, the FeatureLayer is the view, while the FeatureTable is the model. Use the FeatureLayer to manipulate how the data displays on the map. For example, you can manipulate the opacity of the layer, turn labels on or off, and set a different Renderer through the FeatureLayer. The FeatureTable contains the data, and can be used for querying or editing the data.

Feature layer adopts the loadable pattern; many of its properties are initialized asynchronously. See Loadable for more information.

The feature layer has a load dependency on its featureTable from where it gets information about itself, such as minimum and maximum scale, renderer, and so on.

To display features in a FeatureCollectionTable, use FeatureCollectionLayer instead.

Features are retrieved as needed by the app. Features can be downloaded from a sync-enabled feature service when the device is connected and cached locally for use when the device is offline. Edits can then be synchronized back to the service.

Functional characteristics

The following sources can be rendered using a feature layer:

  • Feature service - backed by a service feature table. Feature data from the service is cached locally in the table. New features are retrieved automatically when you navigate the map. The local table cache is discarded when the layer is disposed. If sync is enabled, features can be created, edited, and pushed to the server.
  • Geodatabase - backed by a geodatabase feature table. The geodatabase can be a replica of a feature service, which allows synchronizing with a feature service, or taking the content of a feature service offline. Use a geodatabase sync task to synchronize the geodatabase with the service.
  • Shapefile - backed by a shapefile feature table. Use a feature layer to show the contents of shapefiles (.shp).
  • Geopackage - backed by a geopackage feature table. Use a feature layer to render the tables in a GeoPackage (.gpkg). A GeoPackage is a data source that conforms to the OGC GeoPackage specification. Geopackage feature tables can be edited and saved, but can't support sync, because there is no backing feature service. ArcGIS Runtime supports GeoPackage versions 1.0, 1.1, and 1.2.
  • Web Feature Service (WFS) - backed by a WFS feature table. You can populate the table using Runtime query parameters or raw XML-encoded GetFeature queries. A WFS feature table only supports manual cache feature request mode. Runtime supports OGC Web Feature Service versions 2.0.0 and 2.0.2.

WFS server implementations are inconsistent in how they expect coordinates to be formatted. Some return and expect coordinates in (x,y) order, while others expect (y,x). The Runtime SDK guesses the correct order by default. This behavior can be configured with the WfsFeatureTable::axisOrder and WfsFeatureTable::filterAxisOrder properties.

Individual features can be queried and filtered based on spatial queries or SQL queries. String comparisons for features queried in service feature tables are case insensitive.

Unsupported JSON properties exposed

Feature layers expose a FeatureLayer::unsupportedJson property that, for feature layers based on a feature service, returns a dictionary of values known to the supported web map specification but not explicitly exposed through the Runtime API. This lets you access information that was saved with the layer but not used by Runtime. Feature layers also provide a FeatureLayer::unknownJson property to return JSON that was not recognized.

Performance characteristics

As full feature information is cached locally in a geodatabase, shapefile, or GeoPackage, and features are drawn natively, this layer type offers excellent display performance when zooming and panning the map within the extent of cached features. Querying features is also efficient, enabling app functions such as real-time updates of query results in a map.

The local cache must be initially created, which can be resource-intensive for the server. The initial download to the device may require extensive network usage and subsequent local device storage. App memory increases with the number and complexity of the features cached. Network usage can be eliminated by provisioning the cache directly to the device in advance.

Feature tables backed by a service define three feature request modes. The table's feature request mode controls how and when features are requested from the service:

Calling load() on the feature layer initiates loading of its featureTable also.

Example:

Display a feature service on a map using a FeatureLayer and ServiceFeatureTable:

Map {
    BasemapTerrainWithLabels {}
    initialViewpoint: vc

    FeatureLayer {
        ServiceFeatureTable {
            url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/9"
        }
    }
}

To display features from a mobile geodatabase, create the Geodatabase, obtain a GeodatabaseFeatureTable, and set the table to the FeatureLayer:

// create a feature layer
FeatureLayer {
    // obtain the feature table from the geodatabase by name
    featureTable: gdb.geodatabaseFeatureTablesByTableName["Trailheads"] ?
                      gdb.geodatabaseFeatureTablesByTableName["Trailheads"] :
                      null

    // create the geodatabase
    Geodatabase {
        id: gdb
        path: dataPath + "geodatabase/LA_Trails.geodatabase"

        onErrorChanged: errorMessage = error.message;
    }

    onErrorChanged: errorMessage = error.message;
}

Note: The FeatureLayer will automatically re-project on-the-fly. For example, a FeatureLayer that is in WKID 4326 could be added to a Map that is in WKID 3857, and the FeatureLayer would project on-the-fly to WKID 3857. This is the case for a FeatureLayer using either a ServiceFeatureTable or a GeodatabaseFeatureTable.

This QML type supports the following default properties. A default property may be declared inside another declared object without being assigned explicitly to a property.

TypeDefault Property
FeatureTablefeatureTable
Rendererrenderer
LabelDefinitionlabelDefinitions (since Esri.ArcGISRuntime 100.1) (appends to model)
LayerScenePropertiessceneProperties (since Esri.ArcGISRuntime 100.2)
ArcGISItemitem (since Esri.ArcGISRuntime 100.3)

Example:

Display a feature service on a map using a FeatureLayer and ServiceFeatureTable:

Map {
    BasemapTerrainWithLabels {}
    initialViewpoint: vc

    FeatureLayer {
        ServiceFeatureTable {
            url: "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/9"
        }
    }
}

To display features from a mobile geodatabase, create the Geodatabase, obtain a GeodatabaseFeatureTable, and set the table to the FeatureLayer:

// create a feature layer
FeatureLayer {
    // obtain the feature table from the geodatabase by name
    featureTable: gdb.geodatabaseFeatureTablesByTableName["Trailheads"] ?
                      gdb.geodatabaseFeatureTablesByTableName["Trailheads"] :
                      null

    // create the geodatabase
    Geodatabase {
        id: gdb
        path: dataPath + "geodatabase/LA_Trails.geodatabase"

        onErrorChanged: errorMessage = error.message;
    }

    onErrorChanged: errorMessage = error.message;
}

Note: The FeatureLayer will automatically re-project on-the-fly. For example, a FeatureLayer that is in WKID 4326 could be added to a Map that is in WKID 3857, and the FeatureLayer would project on-the-fly to WKID 3857. This is the case for a FeatureLayer using either a ServiceFeatureTable or a GeodatabaseFeatureTable.

Note: You cannot create a FeatureLayer from a FeatureCollectionTable.

For samples, see:

See also Cancelable, LayerContent, Loadable, PopupSource, and TimeAware.

Property Documentation

definitionExpression : string

The definition expression in the syntax of a SQL WHERE clause by which to limit which features are displayed on the map.

The definition expression string uses the SQL-92 WHERE clause syntax. Be sure to escape special characters in the expression string as required for your platform. The DATE keyword expects the date format yyyy-mm-dd and the TIMESTAMP keyword expects the time stamp format yyyy-mm-dd hh:mm:ss. See the ArcGIS Blog article Querying Feature Services Date-Time Queries for more information.


[default] featureTable : FeatureTable

The backing dataset whose features are drawn on the map by this layer.

This property cannot be set after the layer has started loading.


fullTimeExtent : TimeExtent

Returns the full time extent of the time aware layer (read-only).

Note: This property is only available after the time aware layer is loaded.

This property was introduced in Esri.ArcGISRuntime 100.3.

See also TimeExtent.


[default] item : ArcGISItem

The item being used by the feature layer.

The Item represents a feature layer on ArcGIS Online or an ArcGIS Enterprise portal.

This property must be set along with the serviceLayerId property. Failure to set both properties will result in the layer failing to load.

The item cannot be changed after the layer is loaded.

This property was introduced in Esri.ArcGISRuntime 100.3.


[default] labelDefinitions : LabelDefinitionListModel

Returns the list model of label definitions applied to the layer (read-only).


labelsEnabled : bool

Whether features will be labeled on the map.


popupDefinition : PopupDefinition

See also PopupSource.


popupEnabled : bool

See also PopupSource.


refreshInterval : int

The refresh interval used by the layer in milliseconds.

Layers request features from the service each time this interval elapses.

A value of 0 means to never refresh.

Note: The value is treated as unsigned and cannot be negative.

This property was introduced in Esri.ArcGISRuntime 100.1.


[default] renderer : Renderer

The renderer specifying how the features should be symbolized.


renderingMode : Enums.FeatureRenderingMode

The rendering mode of the feature layer.

The default value is Enums.FeatureRenderingModeAutomatic.

This property was introduced in Esri.ArcGISRuntime 100.2.

See also Enums.FeatureRenderingMode.


scaleSymbols : bool

Whether the sublayer renders its symbols based on scale.

A value of false means the symbols stay the same size in screen units regardless of the map scale.

The default value is false.

This property was introduced in Esri.ArcGISRuntime 100.5.


[default] sceneProperties : LayerSceneProperties

The layer scene properties that can be used to make changes to how features are displayed in a SceneView.

These settings will have no effect if the layer is displayed in a MapView.

This property was introduced in Esri.ArcGISRuntime 100.2.


selectFeaturesResult : FeatureQueryResult

A collection of selected features, the result of the last successful select features task.


selectFeaturesStatus : Enums.TaskStatus

The status for the task to select features.

See also Enums.TaskStatus.


selectedFeaturesResult : FeatureQueryResult

A collection of selected features, the result of the last successful get selected features task.


selectedFeaturesStatus : Enums.TaskStatus

The status for the task to retrieve the collection of selected features.

See also Enums.TaskStatus.


serviceLayerId : string

The service layer ID being used by the feature layer.

Note: The underlying Runtime property is represented as a 64-bit integer type. See Accessing 64-bit integer properties from QML.

This property must be set along with the item property. Failure to set both properties will result in the layer failing to load.

The service layer ID cannot be changed after the layer is loaded.

This property was introduced in Esri.ArcGISRuntime 100.3.

See also serviceLayerIdAsInt.


serviceLayerIdAsInt : double

The same as serviceLayerId but represented as an integer type.

The service layer ID cannot be changed after the layer is loaded.

Note: The underlying Runtime property is represented as a 64-bit integer type. See Accessing 64-bit integer properties from QML.

This property was introduced in Esri.ArcGISRuntime 100.3.


supportsTimeFiltering : bool

Returns whether the time aware layer supports filtering its contents by time values (read-only).

This property was introduced in Esri.ArcGISRuntime 100.3.


timeFilteringEnabled : bool

Returns whether the time aware layer participates in filtering based on the time extent of its geo view.

This property was introduced in Esri.ArcGISRuntime 100.3.


timeInterval : TimeValue

Returns a time interval that represents the suggested step size for use when manipulating the time extent (read-only).

This information can be used to set the step size for a time slider control.

Note: This property is only available after the time aware layer is loaded.

This property was introduced in Esri.ArcGISRuntime 100.3.

See also TimeValue.


timeOffset : TimeValue

The time offset of the time aware layer.

The time offset is subtracted from the time extent set on the time aware layer's geo view. This can be used to overlay data from different periods of time for comparison.

Note: This property is only available after the layer is loaded.

This property was introduced in Esri.ArcGISRuntime 100.3.

See also TimeValue.


unknownJson : jsobject

Returns unknown JSON data from the source JSON. (read-only).

Unknown JSON data consists of values that are in the source JSON but not parsed by ArcGIS Runtime.

This property was introduced in Esri.ArcGISRuntime 100.7.


unsupportedJson : jsobject

Returns unsupported JSON data from the source JSON. (read-only).

Unsupported JSON data consists of values that are supported by web maps, but are not exposed through the ArcGIS Runtime API.

This property was introduced in Esri.ArcGISRuntime 100.7.


Signal Documentation

definitionExpressionChanged()

Emitted when the definitionExpression property changes.

Note: The corresponding handler is onDefinitionExpressionChanged.


featureTableChanged()

Emitted when the featureTable property changes.

Note: The corresponding handler is onFeatureTableChanged.


fullTimeExtentChanged()

Emitted when the fullTimeExtent property of the time aware layer changes.

Note: The corresponding handler is onFullTimeExtentChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


labelDefinitionsChanged()

Emitted when the labelDefinitions property changes.

Note: The corresponding handler is onLabelDefinitionsChanged.

This signal was introduced in Esri.ArcGISRuntime 100.1.


labelsEnabledChanged()

Emitted when the labelsEnabled property changes.

Note: The corresponding handler is onLabelsEnabledChanged.


popupDefinitionChanged()

Emitted when the popupDefinition property changes.

Note: The corresponding handler is onPopupDefinitionChanged.


popupEnabledChanged()

Emitted when the popupEnabled property changes.

Note: The corresponding handler is onPopupEnabledChanged.


refreshIntervalChanged()

Emitted when the refreshInterval property changes.

Note: The corresponding handler is onRefreshIntervalChanged.

This signal was introduced in Esri.ArcGISRuntime 100.1.


rendererChanged()

Emitted when the renderer property changes.

Note: The corresponding handler is onRendererChanged.


renderingModeChanged()

Emitted when the renderingMode property changes.

Note: The corresponding handler is onRenderingModeChanged.

This signal was introduced in Esri.ArcGISRuntime 100.2.


scaleSymbolsChanged()

Emitted when the scaleSymbols property changes.

Note: The corresponding handler is onScaleSymbolsChanged.

This signal was introduced in Esri.ArcGISRuntime 100.5.


scenePropertiesChanged()

Emitted when the sceneProperties property changes.

Note: The corresponding handler is onScenePropertiesChanged.

This signal was introduced in Esri.ArcGISRuntime 100.2.


selectFeaturesStatusChanged()

Emitted when the selectFeaturesStatus property changes.

Note: The corresponding handler is onSelectFeaturesStatusChanged.


selectedFeaturesStatusChanged()

Emitted when the selectedFeaturesStatus property changes.

Note: The corresponding handler is onSelectedFeaturesStatusChanged.


selectionColorChanged()

Emitted when the selectionColor property changes.

Note: The corresponding handler is onSelectionColorChanged.


selectionWidthChanged()

Emitted when the selectionWidth property changes.

Note: The corresponding handler is onSelectionWidthChanged.


serviceLayerIdAsIntChanged()

Emitted when the serviceLayerIdAsInt property changes.

Note: The corresponding handler is onServiceLayerIdAsIntChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


serviceLayerIdChanged()

Emitted when the serviceLayerId property changes.

Note: The corresponding handler is onServiceLayerIdChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


supportsTimeFilteringChanged()

Emitted when the supportsTimeFiltering property of the time aware layer changes.

Note: The corresponding handler is onSupportsTimeFilteringChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


timeFilteringEnabledChanged()

Emitted when the timeFilteringEnabled property of the time aware layer changes.

Note: The corresponding handler is onTimeFilteringEnabledChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


timeIntervalChanged()

Emitted when the timeInterval property of the time aware layer changes.

Note: The corresponding handler is onTimeIntervalChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


timeOffsetChanged()

Emitted when the timeOffset property of the time aware layer changes.

Note: The corresponding handler is onTimeOffsetChanged.

This signal was introduced in Esri.ArcGISRuntime 100.3.


Method Documentation

bool cancelTask(taskId)

Cancel the task with the ID taskId.

Returns false if the task cannot be cancelled or there is no task with the specified id taskId.

See also Cancelable.


void clearSelection()

Clears selection on all features.


void resetFeaturesVisible()

Resets all features back to visible state.


void resetRenderer()

Resets the renderer back to the original renderer provided by the feature table.

This is useful if you change the renderer and then want to revert back to the original renderer.


void selectFeature(feature)

Selects a feature, adding it to the current selection set.


void selectFeatures(features)

Selects multiple features, adding them to the current selection set.


void selectFeaturesWithQuery(parameters, SelectionMode mode)

Queries for features and selects them, adding them to the current selection set.

This method uses an asynchronous task that cannot be started if it is already running from a previous call to selectFeaturesWithQuery. You should check that the selectFeaturesStatus property is not Enums.TaskStatusInProgress before calling this method.

After the task starts, you may use the signal selectFeaturesStatusChanged to monitor task status.

Returns a task ID that can be used to cancel the selectFeaturesWithQuery task.

See also Enums.TaskStatus and Cancelable.


void selectedFeatures()

Retrieves a list of selected features.

This method uses an asynchronous task that cannot be started if it is already running from a previous call to selectedFeatures. You should check that the selectedFeaturesStatus property is not Enums.TaskStatusInProgress before calling this method.

After the task starts, you may use the signal selectedFeaturesStatusChanged to monitor task status.

Returns a task ID that can be used to cancel the selectedFeatures task.

See also Cancelable.


void setFeatureVisible(feature, bool visible)

Sets a feature to be visible or invisible.


void setFeaturesVisible(features, bool visible)

Sets multiple features to be visible or invisible.


void unselectFeature(feature)

Unselects a feature, removing it from the current selection set.


void unselectFeatures(features)

Unselects multiple features, removing them from the current selection set.



Feedback on this topic?