import ActiveLayerInfo from "@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

Constructor

Parameters

ParameterTypeDescriptionRequired
properties

The properties used to configure the active layer info.

See the properties table for a list of all the properties that may be passed into the constructor.

Properties

Any properties can be set, retrieved or listened to. See the Watch for changes topic.

children

Property
Type
Collection<ActiveLayerInfo>

A collection of child activeLayerInfos. This only applies to renderers of Sublayers or the children of GroupLayers.

cssEffectFilter

readonly Property
Type
string | null | undefined

The CSS filter string representing the effects applied to the active layer.

declaredClass

readonlyinherited Property
Type
string
Inherited from: Accessor
Since
ArcGIS Maps SDK for JavaScript 4.7

The name of the class. The declared class name is formatted as esri.folder.className.

hideLayersNotInCurrentView

Property
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

readonly Property
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

Property
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

layer

Property
Type
Layer

The layer represented by the ActiveLayerInfo object.

layerView

Property
Type
LayerView

The layerView represented by the ActiveLayerInfo object's layer.

legendElements

Property
Type
LegendElement[]

The legendElements is constructed using the layer Renderer. It reflects the actual structure of the legend.

loading

readonly Property
Type
boolean

Indicates whether legend elements are currently being generated for this layer or its children.

opacity

readonly Property
Type
number

The opacity of the layer or parent element.

parent

Property
Type
ActiveLayerInfo | null | undefined

The ActiveLayerInfo of the parent Sublayer or GroupLayer.

ready

readonly Property
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

Property
Type
boolean

Indicates whether the layer's definition expression should be applied when generating legend information.

Default value
false

respectLayerVisibility

Property
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:

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

scale

readonly Property
Type
number

The scale of the view instance in which the Legend is rendered.

sublayerIds

Property
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

Property
Type
string | null | undefined

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.

version

readonly Property
Type
number

The version of the ActiveLayerInfo. It increases by 1 whenever ready property of ActiveLayerInfo changes. This property should watched in the view for ActiveLayerInfo changes and update the DOM accordingly.

view

Property
Type
MapViewOrSceneView

The view in which the Legend is rendered.