▾
import ActiveLayerInfo from "@arcgis/core/legend/ActiveLayerInfo.js";const ActiveLayerInfo = await $arcgis.import("@arcgis/core/legend/ActiveLayerInfo.js");- Inheritance
- ActiveLayerInfo→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 5.2
Represents the legend content for a layer or sublayer in a LegendModel instance.
An ActiveLayerInfo is added to or removed from
LegendModel.activeLayerInfos as layers become visible or invisible in the view. It maintains
parent and child relationships and generates the legend elements
required to render the layer's symbology.
You can use this class to build custom, interactive legends without using the Legend component.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | The properties used to configure the active layer info. | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| readonly | | |
| readonly inherited | ||
| | ||
| readonly | | |
| | ||
| | ||
| | ||
| | ||
| readonly | | |
| readonly | | |
| | ||
| readonly | | |
| | ||
| | ||
| readonly | | |
| number[] | | |
| | ||
| readonly | | |
| |
children
- Type
- Collection<ActiveLayerInfo>
A collection of child activeLayerInfos. This only applies to renderers of Sublayers or the children of GroupLayers.
hideLayersNotInCurrentView
- Type
- boolean
When true, layers will only be shown in the legend if
they are visible in the view's extent. When data from a layer
is not visible in the view, the layer's legend information
will be hidden.
To hide layers completely
from the legend, you should set the legendEnabled property of
the layer to false.
- See also
- Default value
- false
isScaleDriven
- Type
- boolean
Indicates if the legend's display of the layer's renderer is driven by the scale of the view.
This is true of Sublayer renderers, any renderer that uses
a valueExpression (Arcade expression), DotDensityRenderer, and
layers that have FeatureReductionLayer.featureReduction enabled.
keepCacheOnDestroy
- Type
- boolean
Indicates whether cached legend responses should be preserved when the active layer info is destroyed. Preserving the cache can avoid repeating legend requests when creating another active layer info for the same layer.
- Default value
- false
legendElements
- Type
- LegendElement[]
The legendElements is constructed using the layer Renderer. It reflects the actual structure of the legend.
loading
- Type
- boolean
Indicates whether legend elements are currently being generated for this layer or its children.
parent
- Type
- ActiveLayerInfo | null | undefined
The ActiveLayerInfo of the parent Sublayer or GroupLayer.
ready
- Type
- boolean
Indicates if the activeLayerInfo is ready. It is set to true when all its legendElements are computed.
It is set to false when the layer renderer changes so that the legendElements can recomputed.
respectLayerDefinitionExpression
- Type
- boolean
Indicates whether the layer's definition expression should be applied when generating legend information.
- Default value
- false
respectLayerVisibility
- Type
- boolean
Determines whether to respect the properties of the layers in the map that
control the legend's visibility (minScale, maxScale, legendEnabled).
By default, a layer's legend elements will
not render in the legend given the following conditions:
- The FeatureLayer.legendEnabled property
is set to
false. - If the view's scale is outside the visibility range defined by the ScaleRangeLayer.minScale and ScaleRangeLayer.maxScale properties.
When the respectLayerVisibility property of the legend is set to false, the legend elements for each
layer in the map will always display, thus disregarding the minScale, maxScale,
and legendEnabled properties for each layer in the map.
- See also
- Default value
- true
sublayerIds
- Type
- number[]
Only applies if the layer is a MapImageLayer. An array of MapImageLayer Sublayer IDs for which to display legend information. For example, if a MapImageLayer contains 100 sublayers, but you want to display the legend for two sublayers, then specifying the IDs of both sublayers will allow the Legend to only display legend information for those sublayers.
title
The text string that represents the legend's title. This value is read from the layerInfo of the
corresponding layer in the legend. If not provided, this value comes from the
Layer.title.