Skip To Content ArcGIS for Developers Sign In Dashboard

FeatureLayer Class

class Esri::ArcGISRuntime::FeatureLayer

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

Header: #include <FeatureLayer>
Since: Esri::ArcGISRuntime 100.0
Inherits: Esri::ArcGISRuntime::Layer, Esri::ArcGISRuntime::PopupSource, and Esri::ArcGISRuntime::TimeAware
Inherited By:

Esri::ArcGISRuntime::SubtypeFeatureLayer

This class was introduced in Esri::ArcGISRuntime 100.0.

Public Functions

FeatureLayer(Esri::ArcGISRuntime::Item *item, qint64 serviceLayerId, QObject *parent = nullptr)
FeatureLayer(Esri::ArcGISRuntime::FeatureTable *featureTable, QObject *parent = nullptr)
virtual ~FeatureLayer() override
void clearSelection()
QString definitionExpression() const
Esri::ArcGISRuntime::FeatureTable *featureTable() const
bool isLabelsEnabled() const
bool isScaleSymbols() const
Esri::ArcGISRuntime::LabelDefinitionListModel *labelDefinitions() const
quint64 refreshInterval() const
Esri::ArcGISRuntime::Renderer *renderer() const
Esri::ArcGISRuntime::FeatureRenderingMode renderingMode() const
void resetFeaturesVisible()
void resetRenderer()
Esri::ArcGISRuntime::LayerSceneProperties sceneProperties() const
void selectFeature(Esri::ArcGISRuntime::Feature *feature)
void selectFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)
Esri::ArcGISRuntime::TaskWatcher selectFeatures(const Esri::ArcGISRuntime::QueryParameters &parameters, Esri::ArcGISRuntime::SelectionMode mode)
Esri::ArcGISRuntime::TaskWatcher selectedFeatures()
qint64 serviceLayerId() const
void setDefinitionExpression(const QString &expression)
void setFeatureVisible(Esri::ArcGISRuntime::Feature *feature, bool visible)
void setFeaturesVisible(const QList<Esri::ArcGISRuntime::Feature *> &features, bool visible)
void setLabelsEnabled(bool enabled)
void setRefreshInterval(quint64 milliseconds)
void setRenderer(Esri::ArcGISRuntime::Renderer *renderer)
void setRenderingMode(Esri::ArcGISRuntime::FeatureRenderingMode renderingMode)
void setScaleSymbols(bool scaleSymbols)
void setSceneProperties(const Esri::ArcGISRuntime::LayerSceneProperties &sceneProperties)
QJsonObject unknownJson() const
void unselectFeature(Esri::ArcGISRuntime::Feature *feature)
void unselectFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)
QJsonObject unsupportedJson() const

Reimplemented Public Functions

virtual Esri::ArcGISRuntime::TimeExtent fullTimeExtent() const override
virtual bool isPopupEnabled() const override
virtual bool isSupportsTimeFiltering() const override
virtual bool isTimeFilteringEnabled() const override
virtual Esri::ArcGISRuntime::PopupDefinition *popupDefinition() const override
virtual void setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition) override
virtual void setPopupEnabled(bool popupEnabled) override
virtual void setTimeFilteringEnabled(bool timeFilteringEnabled) override
virtual void setTimeOffset(const Esri::ArcGISRuntime::TimeValue &timeOffset) override
virtual Esri::ArcGISRuntime::TimeValue timeInterval() const override
virtual Esri::ArcGISRuntime::TimeValue timeOffset() const override

Signals

void fullTimeExtentChanged()
void selectFeaturesCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)
void selectedFeaturesCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)

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:

// create the feature table
m_featureTable = new ServiceFeatureTable(QUrl("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/9"), this);

// create the feature layer using the feature table
m_featureLayer = new FeatureLayer(m_featureTable, this);

// add the feature layer to the map
m_map->operationalLayers()->append(m_featureLayer);

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

// access the feature table by name
GeodatabaseFeatureTable* featureTable = m_geodatabase->geodatabaseFeatureTable("Trailheads");

// create a feature layer from the feature table
FeatureLayer* featureLayer = new FeatureLayer(featureTable, this);

Note: The FeatureLayer will automatically reproject 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.

For samples, see:

  • {https://developers.arcgis.com/qt/latest/cpp/sample-code/feature-layer-geodatabase/} {Feature layer (geodatabase)}
  • {sample-feature-layer-query}https://developers.arcgis.com/qt/latest/cpp/sample-code/feature-layer-query/} {Feature layer query}
  • {https://developers.arcgis.com/qt/latest/cpp/sample-code/feature-layer-shapefile/} {Feature layer (shapefile)}
  • {sample-feature-layer-feature-service}https://developers.arcgis.com/qt/latest/cpp/sample-code/feature-layer-feature-service/} {Feature layer (feature service)}
  • {https://developers.arcgis.com/qt/latest/cpp/sample-code/service-feature-table-manual-cache/} {Service feature table (manual cache)}

See also Layer and PopupSource.

Member Function Documentation

FeatureLayer::FeatureLayer(Esri::ArcGISRuntime::Item *item, qint64 serviceLayerId, QObject *parent = nullptr)

Initialize the layer with the given item, serviceLayerId, and optional parent.

This function was introduced in Esri::ArcGISRuntime 100.3.

FeatureLayer::FeatureLayer(Esri::ArcGISRuntime::FeatureTable *featureTable, QObject *parent = nullptr)

Initialize the layer with the given featureTable and optional parent.

The feature table is the backing dataset whose features need to be drawn on the map by this layer.

Note: You cannot create a FeatureLayer from a FeatureCollectionTable.

[signal] void FeatureLayer::fullTimeExtentChanged()

Signal emitted when the fullTimeExtent changes.

See also TimeAware.

[signal] void FeatureLayer::selectFeaturesCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)

Signal emitted when a selection of features from a query operation has completed.

  • taskId - The task ID for the asynchronous operation.
  • featureQueryResult - A feature query result containing an iterator pointing to the selected features from the query.

The returned FeatureQueryResult object has the FeatureLayer as its parent.

See also Returned QObjects Parenting.

[signal] void FeatureLayer::selectedFeaturesCompleted(QUuid taskId, Esri::ArcGISRuntime::FeatureQueryResult *featureQueryResult)

Signal emitted when the current selected features have been determined.

  • taskId - The task ID for the asynchronous operation.
  • featureQueryResult - A feature query result containing an iterator pointing to the selected features.

The returned FeatureQueryResult object has the FeatureLayer as its parent.

See also Returned QObjects Parenting.

[override virtual] FeatureLayer::~FeatureLayer()

Destructor.

void FeatureLayer::clearSelection()

Clears selection on all features.

QString FeatureLayer::definitionExpression() const

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

See also setDefinitionExpression().

Esri::ArcGISRuntime::FeatureTable *FeatureLayer::featureTable() const

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

[override virtual] Esri::ArcGISRuntime::TimeExtent FeatureLayer::fullTimeExtent() const

Reimplements: TimeAware::fullTimeExtent() const.

Returns the full time extent of the layer.

This function was introduced in Esri::ArcGISRuntime 100.3.

bool FeatureLayer::isLabelsEnabled() const

Returns true if features will be labeled on the map.

[override virtual] bool FeatureLayer::isPopupEnabled() const

Reimplements: PopupSource::isPopupEnabled() const.

Returns whether the Popup is enabled on the PopupSource.

bool FeatureLayer::isScaleSymbols() const

Returns 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 function was introduced in Esri::ArcGISRuntime 100.5.

[override virtual] bool FeatureLayer::isSupportsTimeFiltering() const

Reimplements: TimeAware::isSupportsTimeFiltering() const.

Returns whether the layer supports filtering its contents by time values.

This function was introduced in Esri::ArcGISRuntime 100.3.

[override virtual] bool FeatureLayer::isTimeFilteringEnabled() const

Reimplements: TimeAware::isTimeFilteringEnabled() const.

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

This function was introduced in Esri::ArcGISRuntime 100.3.

Esri::ArcGISRuntime::LabelDefinitionListModel *FeatureLayer::labelDefinitions() const

Returns the list model of label definitions in the layer.

This function was introduced in Esri::ArcGISRuntime 100.1.

[override virtual] Esri::ArcGISRuntime::PopupDefinition *FeatureLayer::popupDefinition() const

Reimplements: PopupSource::popupDefinition() const.

See PopupSource.

See also setPopupDefinition().

quint64 FeatureLayer::refreshInterval() const

Returns 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.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also setRefreshInterval().

Esri::ArcGISRuntime::Renderer *FeatureLayer::renderer() const

Returns the renderer specifying how the features should be symbolized.

See also setRenderer().

Esri::ArcGISRuntime::FeatureRenderingMode FeatureLayer::renderingMode() const

Gets the rendering mode of the feature layer.

The default value is FeatureRenderingMode::Automatic.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also setRenderingMode().

void FeatureLayer::resetFeaturesVisible()

Resets all features back to visible state.

void FeatureLayer::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.

Esri::ArcGISRuntime::LayerSceneProperties FeatureLayer::sceneProperties() const

Gets 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 function was introduced in Esri::ArcGISRuntime 100.2.

See also setSceneProperties().

void FeatureLayer::selectFeature(Esri::ArcGISRuntime::Feature *feature)

Adds the feature to the current selection set.

void FeatureLayer::selectFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)

Adds multiple features to the current selection set.

Esri::ArcGISRuntime::TaskWatcher FeatureLayer::selectFeatures(const Esri::ArcGISRuntime::QueryParameters &parameters, Esri::ArcGISRuntime::SelectionMode mode)

Selects features, asynchronously, based on query parameters and selection mode and returns a TaskWatcher for the asynchronous operation.

Esri::ArcGISRuntime::TaskWatcher FeatureLayer::selectedFeatures()

Launches a task to retrieve a collection of selected features, and returns a TaskWatcher for the asynchronous task.

qint64 FeatureLayer::serviceLayerId() const

Returns the service layer ID in the feature service that this layer was created from.

This function was introduced in Esri::ArcGISRuntime 100.3.

void FeatureLayer::setDefinitionExpression(const QString &expression)

Sets 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.

See also definitionExpression().

void FeatureLayer::setFeatureVisible(Esri::ArcGISRuntime::Feature *feature, bool visible)

Sets a feature to be visible or invisible.

void FeatureLayer::setFeaturesVisible(const QList<Esri::ArcGISRuntime::Feature *> &features, bool visible)

Sets multiple features to be visible or invisible.

void FeatureLayer::setLabelsEnabled(bool enabled)

Sets whether labels are enabled on features in layer.

See also isLabelsEnabled().

[override virtual] void FeatureLayer::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition)

Reimplements: PopupSource::setPopupDefinition(Esri::ArcGISRuntime::PopupDefinition *popupDefinition).

Sets the popup definition to popupDefinition.

See also popupDefinition() and PopupSource.

[override virtual] void FeatureLayer::setPopupEnabled(bool popupEnabled)

Reimplements: PopupSource::setPopupEnabled(bool popupEnabled).

Sets whether the PopupSource is enabled to popupEnabled.

See also isPopupEnabled() and PopupSource.

void FeatureLayer::setRefreshInterval(quint64 milliseconds)

Sets the refresh interval used by the layer to milliseconds.

Layers request features from the service each time this interval elapses

A value of 0 means to never refresh.

This function was introduced in Esri::ArcGISRuntime 100.1.

See also refreshInterval().

void FeatureLayer::setRenderer(Esri::ArcGISRuntime::Renderer *renderer)

Sets the renderer specifying how the features should be symbolized.

See also renderer().

void FeatureLayer::setRenderingMode(Esri::ArcGISRuntime::FeatureRenderingMode renderingMode)

Sets the rendering mode of the feature layer to renderingMode.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also renderingMode().

void FeatureLayer::setScaleSymbols(bool scaleSymbols)

Sets whether the sublayer renders its symbols based on scale to scaleSymbols.

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 function was introduced in Esri::ArcGISRuntime 100.5.

See also isScaleSymbols().

void FeatureLayer::setSceneProperties(const Esri::ArcGISRuntime::LayerSceneProperties &sceneProperties)

Sets layer scene properties to sceneProperties, which can be used to make changes to how features are displayed in a SceneView.

This function was introduced in Esri::ArcGISRuntime 100.2.

See also sceneProperties().

[override virtual] void FeatureLayer::setTimeFilteringEnabled(bool timeFilteringEnabled)

Reimplements: TimeAware::setTimeFilteringEnabled(bool timeFilteringEnabled).

Sets whether the layer uses the time range defined on the geo view to timeFilteringEnabled.

This function was introduced in Esri::ArcGISRuntime 100.3.

See also isTimeFilteringEnabled().

[override virtual] void FeatureLayer::setTimeOffset(const Esri::ArcGISRuntime::TimeValue &timeOffset)

Reimplements: TimeAware::setTimeOffset(const Esri::ArcGISRuntime::TimeValue &timeOffset).

Sets the time offset of the layer to timeOffset.

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

This function was introduced in Esri::ArcGISRuntime 100.3.

See also timeOffset().

[override virtual] Esri::ArcGISRuntime::TimeValue FeatureLayer::timeInterval() const

Reimplements: TimeAware::timeInterval() const.

Returns a time interval that represents the suggested step size for use when manipulating the time extent.

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

This function was introduced in Esri::ArcGISRuntime 100.3.

[override virtual] Esri::ArcGISRuntime::TimeValue FeatureLayer::timeOffset() const

Reimplements: TimeAware::timeOffset() const.

Returns the applied time offset.

This function was introduced in Esri::ArcGISRuntime 100.3.

See also setTimeOffset().

QJsonObject FeatureLayer::unknownJson() const

Returns unknown JSON data from the source JSON.

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

This function was introduced in Esri::ArcGISRuntime 100.7.

void FeatureLayer::unselectFeature(Esri::ArcGISRuntime::Feature *feature)

Unselects and removes a feature from the current selection.

void FeatureLayer::unselectFeatures(const QList<Esri::ArcGISRuntime::Feature *> &features)

Unselects and removes features from the current selection.

QJsonObject FeatureLayer::unsupportedJson() const

Returns the unsupported JSON data from the source JSON.

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

This function was introduced in Esri::ArcGISRuntime 100.7.


Feedback on this topic?