import ActiveLayerInfo from "@arcgis/core/widgets/Legend/support/ActiveLayerInfo.js";const ActiveLayerInfo = await $arcgis.import("@arcgis/core/widgets/Legend/support/ActiveLayerInfo.js");- Inheritance:
- ActiveLayerInfo→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.11
ActiveLayerInfo is added to or removed from the collection of Legend.activeLayerInfos as layers become visible or invisible in the view. You can use this module to make the Legend more interactive.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
cssEffectFilter readonly | | |
declaredClass readonly inherited | ||
| | ||
isScaleDriven readonly | | |
| | ||
| | ||
| | ||
opacity readonly | | |
| | ||
ready readonly | | |
| | ||
scale readonly | | |
number[] | | |
| | ||
version 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
- Since
- ArcGIS Maps SDK for JavaScript 4.21
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
Example
// layers not displayed in the view// will not be shown in the legendlegend.hideLayersNotInCurrentView = true; 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.
legendElements
- Type
- LegendElement[]
The legendElements is constructed using the layer Renderer. It reflects the actual structure of the legend.
opacity
- Type
- number
- Since
- ArcGIS Maps SDK for JavaScript 4.17
The opacity of the layer or parent element.
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.
respectLayerVisibility
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.13
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
Example
// Always displays legend elements for the map's layers// regardless of their minScale, maxScale, and legendEnabled propertieslegend.respectLayerVisibility = false; sublayerIds
- Type
- number[]
- Since
- ArcGIS Maps SDK for JavaScript 4.23
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.
Example
// Only displays legend items for sublayers 1 and 2activeLayerInfo.sublayerIds = [1, 2]; 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.