FeatureLayer

open class FeatureLayer : Layer, FloorAware, PopupSource, Refreshable, TimeAware

A layer that can visualize vector/feature data. Feature layers display feature data from an online ServiceFeatureTable source, or from offline sources such as GeodatabaseFeatureTable, ShapefileFeatureTable, or GeoPackageFeatureTable. 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 can also be used to store features associated with a utility network.

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 feature service table. The 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 the feature service, or taking the content of a feature service offline. Use a geodatabase sync task to synchronize the geodatabase with the service. The geodatabase can also be a mobile geodatabase created by ArcGIS Pro. Mobile geodatabases cannot be synced and use a default renderer.

  • Shapefile - backed by a shapefile feature table. Uses a feature layer to show the contents of shapefiles (.shp).

  • Geopackage - backed by a geopackage feature table. This uses a feature layer to render the tables in a GeoPackage (.gpkg). A GeoPackage is a data source that conforms to the https://www.ogc.org/standards/geopackage. Geopackage feature tables can be edited and saved, but can't support sync, because there is no backing feature service. This API 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 QueryParameters or raw XML-encoded GetFeature queries. A WFS feature table only supports the manual cache feature request mode. This API supports OGC WFS[https://www.ogc.org/standards/wfs] 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). This API anticipates the order but you can configure it with the WfsFeatureTable.getAxisOrder() and WfsFeatureTable.getFilterAxisOrder().

  • OGC API Features - Backed by an OGC feature collection table. You can populate the table using QueryParameters. An OCG feature collection table only supports the manual cache feature request mode. This API supports OGC API - Features - Part 1[https://docs.opengeospatial.org/is/17-069r3/17-069r3.html] and https://docs.opengeospatial.org/is/18-058/18-058.html.

Individual features can be queried and filtered based on spatial queries or SQL queries. Introduced at 100.3.0, string comparisons for features queried in service feature tables are case insensitive.

The features displayed in a FeatureLayer are reprojected to match the GeoModel.getSpatialReference(), if necessary. Local tables cannot be reprojected automatically.

The FeatureLayer does not expose every value defined in the web map specification. You can obtain a dictionary of these unsupported values from FeatureLayer.getUnsupportedJson(). The FeatureLayer also provides FeatureLayer.getUnknownJson() to return JSON that was not recognized in the web map specification.

Performance characteristics

Because 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 usage 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:

  • On interaction cache - Features are requested automatically for the visible map or scene extent. As the user pans and zooms, features are cached locally. If the user returns to an area where features have already been loaded, the table won't need to download those features again.

  • Manual cache - Features must be manually populated using a call to ServiceFeatureTable.populateFromService(QueryParameters, Boolean, MutableListImpl). Once populated, all queries are made against the local table only. ServiceFeatureTable.populateFromService(QueryParameters, Boolean, MutableListImpl) can be called again to retrieve more features from the service.

  • On interaction, no cache - Features are requested automatically for the visible map extent. As the user pans and zooms, features outside the visible extent are not cached and must be downloaded again each time.

See also

Constructors

Link copied to clipboard
fun FeatureLayer(featureTable: FeatureTable)

Creates a new feature layer object. Any of the inherited FeatureTable types can be used as the input parameter for this constructor, including the ArcGISFeatureTable, FeatureCollectionTable, GeoPackageFeatureTable, OgcFeatureCollectionTable, ShapefileFeatureTable, and WfsFeatureTable.

Link copied to clipboard
fun FeatureLayer(item: Item)

Creates a new feature layer object from a feature layer or feature service portal item. If the portal item is a feature service, the FeatureLayer will be created from the first layer on the service.

Link copied to clipboard
fun FeatureLayer(item: Item, layerId: Long)

Creates a new feature layer object from a feature service portal item. The FeatureLayer will fail to load if an invalid portal item is passed in, for example a feature layer portal item.

Functions

Link copied to clipboard
open override fun cancelLoad()

Cancels loading metadata for the Loadable object.

Link copied to clipboard
fun clearSelection()

Clears all selected features.

Link copied to clipboard
open override fun clone(): FeatureLayer

Clones the FeatureLayer.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open suspend override fun fetchLegendInfos(): Result<List<LegendInfo>>

Fetches the list of legend info.

Link copied to clipboard
suspend fun getSelectedFeatures(): Result<FeatureQueryResult>

Returns a list of the currently selected features.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun isVisibleAtScale(scale: Double): Boolean

Returns the layer content's effective visibility at the specified scale. Returns the effective layer content visibility. This effective visibility takes care of the effective visibility of the parents at the specified scale. Will return false if an error occurs.

Link copied to clipboard
open suspend override fun load(): Result<Unit>

Loads the metadata for the object.

Link copied to clipboard
fun resetFeaturesVisible()

Resets the layer's features visibility back to factory defaults.

Link copied to clipboard
fun resetRenderer()

Resets the renderer to the factory default.

Link copied to clipboard
open suspend override fun retryLoad(): Result<Unit>

Loads or retries loading metadata for the object.

Link copied to clipboard
fun selectFeature(feature: Feature)

Selects the given feature and adds it to the current list of selected features.

Link copied to clipboard
fun selectFeatures(features: Iterable<Feature>)

Selects the features in the list and adds them to the current list of selected features.

suspend fun selectFeatures(parameters: QueryParameters, mode: SelectionMode): Result<FeatureQueryResult>

Selects the features that match the criteria in the QueryParameters object and adds them to the current list of selected features.

Link copied to clipboard
fun setFeaturesVisible(features: Iterable<Feature>, visible: Boolean)

Sets the visibility of the given features.

Link copied to clipboard
fun setFeatureVisible(feature: Feature, visible: Boolean)

Sets the visibility of the given feature.

Link copied to clipboard
fun unselectFeature(feature: Feature)

Unselects the given feature and removes it from the current list of selected features.

Link copied to clipboard
fun unselectFeatures(features: Iterable<Feature>)

Unselects the features in the given list and removes them from the current list of selected features.

Properties

Link copied to clipboard
val attribution: String

The attribution text for the layer.

Link copied to clipboard
open override val canChangeVisibility: Boolean

A flag indicating whether the layer content's visibility can be changed. A flag indicating whether the layer content visibility can be changed. Will return false if an error occurs.

Link copied to clipboard
var definitionExpression: String

A SQL expression which limits the features available for query and display on the feature layer. The definition expression string that is used as the FeatureLayer.getDefinitionExpression() should follow standard SQL syntax similar to what is discussed in the document https://pro.arcgis.com/en/pro-app/latest/help/mapping/navigation/sql-reference-for-elements-used-in-query-expressions.htm.

Link copied to clipboard
var description: String

The description for the layer. The description of the layer.

Link copied to clipboard
var displayFilterDefinition: DisplayFilterDefinition?
Link copied to clipboard
val featureTable: FeatureTable?
Link copied to clipboard
open override var floorDefinition: LayerFloorDefinition?

Defines the properties that allow a layer to be floor-aware. When a layer is configured as floor-aware, it has a FloorAware.getFloorDefinition() property that defines properties that allow a layer to be floor-aware. When it is null (default value) the specific layer does not support floor filtering.

Link copied to clipboard
val fullExtent: Envelope?
Link copied to clipboard
open override val fullTimeExtent: StateFlow<TimeExtent?>

The full time extent of the object. A null if the object is not time aware or if an error occurs.

Link copied to clipboard
var id: String

The unique identifying string for the layer, for example specified in a map or scene. The id is used by other parts of this API to refer to a specific Layer, such as in a set of FeatureFenceParameters or a FacilityLayerDefinition. If not supplied, all layers will be assigned a unique id when created.

Link copied to clipboard
val isIdentifyEnabled: Boolean

Whether the layer supports identify. If the layer is not loaded it may return false if identify support is determined by metadata that is not yet available.

Link copied to clipboard
open override var isPopupEnabled: Boolean

A flag indicating whether the PopupDefinition defined on the PopupSource is enable / disable. Will return false if an error occurs.

Link copied to clipboard
open override var isTimeFilteringEnabled: Boolean

A flag indicating whether the object must use the time extent defined on the owning GeoView to filter its data.

Link copied to clipboard
open override var isVisible: Boolean

The layer content's visibility. The layer content visibility. Will return false if an error occurs.

Link copied to clipboard
val item: Item?
Link copied to clipboard
val labelDefinitions: MutableList<LabelDefinition>
Link copied to clipboard
var labelsEnabled: Boolean

True if labels should be displayed.

Link copied to clipboard
open override val loadStatus: StateFlow<LoadStatus>

The load status.

Link copied to clipboard
var maxScale: Double?

The maximum scale for the layer. If it is null, there is no maximum. This controls the maximum scale level the layer can zoom to. All of the connected map views will be updated.

Link copied to clipboard
var minScale: Double?

The minimum scale for the layer. If it is null, there is no minimum. This controls the minimum scale level the layer can zoom to. All of the connected map views will be updated.

Link copied to clipboard
open override val name: String

The layer content's name. The layer content name.

Link copied to clipboard
var opacity: Float

The opacity for the layer. All of the connected map views will be updated.

Link copied to clipboard
open override var popupDefinition: PopupDefinition?

The pop-up definition. The PopupDefinition associated with the popup source. A null if an error occurs or if the popup source is not associated with a pop-up definition.

Link copied to clipboard
var renderer: Renderer?
Link copied to clipboard
var renderingMode: FeatureRenderingMode

The rendering mode used to render this layer.

Link copied to clipboard
var scaleSymbols: Boolean

Whether the layer's symbols and labels honor the Map reference scale. If the Map has a positive reference scale, and the layer honors it, then symbols and labels will be drawn at their specified size when the viewing scale is the same as the reference scale, and will grow or shrink as the view zooms in or out, to keep the symbol a fixed size on the map. If the Map has no reference scale, the reference scale is zero or the FeatureLayer's scaleSymbols property is false, then the symbols and labels will be drawn at their fixed screen size.

Link copied to clipboard
var sceneProperties: LayerSceneProperties
Link copied to clipboard
open override var showInLegend: Boolean

A flag indicating whether the layer content participates in the legend. A flag indicating whether the layer content is shown in the legend.

Link copied to clipboard
val spatialReference: SpatialReference?
Link copied to clipboard
open override val subLayerContents: StateFlow<List<LayerContent>>

The sub layer contents of a layer content.

Link copied to clipboard
open override val supportsTimeFiltering: Boolean

A flag indicating whether the object supports filtering its contents by time values with the extent set on the owning GeoView.

Link copied to clipboard
var tilingMode: FeatureTilingMode

The feature tiling mode in use by the feature layer. Default is FeatureTilingMode.EnabledWhenSupported. Changes how feature tiling is handled by the feature layer.

Link copied to clipboard
open override val timeInterval: TimeValue?

The suggested time slider step size for this time aware object. Can be null if no time interval is suggested for this time aware object.

Link copied to clipboard
open override var timeOffset: TimeValue?

The time offset applied to this object. The offset is subtracted from the time extent set on the owning GeoView. This allows for data from different periods of time to be compared.

Link copied to clipboard
val unknownJson: Map<String, Any>
Link copied to clipboard
val unsupportedJson: Map<String, Any>
Link copied to clipboard
val visibilityChanged: SharedFlow<Boolean>

Callback invoked when the visibility of the layer changes.

Inheritors

Link copied to clipboard