require(["esri/widgets/Legend/support/ActiveLayerInfo"], (ActiveLayerInfo) => { /* code goes here */ });
import ActiveLayerInfo from "@arcgis/core/widgets/Legend/support/ActiveLayerInfo.js";
esri/widgets/Legend/support/ActiveLayerInfo
ActiveLayerInfo is added to or removed from the collection of activeLayerInfos as layers become visible or invisible in the view. You can use this module to make the Legend more interactive.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
A collection of child activeLayerInfos. | ActiveLayerInfo | ||
The name of the class. | Accessor | ||
When | ActiveLayerInfo | ||
Indicates if the legend's display of the layer's renderer is driven by the scale of the view. | ActiveLayerInfo | ||
The layer represented by the ActiveLayerInfo object. | ActiveLayerInfo | ||
The layerView represented by the ActiveLayerInfo object's layer. | ActiveLayerInfo | ||
The legendElements is constructed using the layer Renderer. | ActiveLayerInfo | ||
The opacity of the layer or parent element. | ActiveLayerInfo | ||
The ActiveLayerInfo of the parent esri/layers/support/ISublayer or GroupLayer. | ActiveLayerInfo | ||
Indicates if the activeLayerInfo is ready. | ActiveLayerInfo | ||
Determines whether to respect the properties of the layers in the map that control the legend's visibility ( | ActiveLayerInfo | ||
The scale of the view instance in which the Legend is rendered. | ActiveLayerInfo | ||
Only applies if the layer is a MapImageLayer. | ActiveLayerInfo | ||
The text string that represents the legend's title. | ActiveLayerInfo | ||
The version of the ActiveLayerInfo. | ActiveLayerInfo | ||
The view in which the Legend is rendered. | ActiveLayerInfo |
Property Details
-
children
children Collection<ActiveLayerInfo>
-
A collection of child activeLayerInfos. This only applies to renderers of Sublayers or the children of GroupLayers.
-
hideLayersNotInCurrentView
hideLayersNotInCurrentView Boolean
Since: ArcGIS Maps SDK for JavaScript 4.21ActiveLayerInfo since 4.11, hideLayersNotInCurrentView added at 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 tofalse
.- Default Value:false
- See also
Example// layers not displayed in the view // will not be shown in the legend legend.hideLayersNotInCurrentView = true;
-
isScaleDriven
isScaleDriven Boolean
-
Indicates if the legend's display of the layer's renderer is driven by the scale of the view. This is true of esri/layers/support/ISublayer renderers, any renderer that uses a
valueExpression
(Arcade expression), DotDensityRenderer, and layers that have clustering enabled.
-
layer
layer Layer
-
The layer represented by the ActiveLayerInfo object.
-
layerView
layerView LayerView
-
The layerView represented by the ActiveLayerInfo object's layer.
-
legendElements
legendElements LegendElement[]
-
The legendElements is constructed using the layer Renderer. It reflects the actual structure of the legend.
-
opacity
opacity Numberreadonly
Since: ArcGIS Maps SDK for JavaScript 4.17ActiveLayerInfo since 4.11, opacity added at 4.17. -
The opacity of the layer or parent element.
-
parent
parent ActiveLayerInfo
-
The ActiveLayerInfo of the parent esri/layers/support/ISublayer or GroupLayer.
-
ready
ready Boolean
-
Indicates if the activeLayerInfo is ready. It is set to
true
when all its legendElements are computed. It is set tofalse
when the layer renderer changes so that the legendElements can recomputed.
-
respectLayerVisibility
respectLayerVisibility Boolean
Since: ArcGIS Maps SDK for JavaScript 4.13ActiveLayerInfo since 4.11, respectLayerVisibility added at 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 layer's legendEnabled property
is set to
false
. - If the view's scale is outside the visibility range defined by the layer's minScale and maxScale properties.
When the
respectLayerVisibility
property of the legend is set tofalse
, the legend elements for each layer in the map will always display, thus disregarding theminScale
,maxScale
, andlegendEnabled
properties for each layer in the map.- Default Value:true
- See also
Example// Always displays legend elements for the map's layers // regardless of their minScale, maxScale, and legendEnabled properties legend.respectLayerVisibility = false;
- The layer's legendEnabled property
is set to
-
scale
scale Number
-
The scale of the view instance in which the Legend is rendered.
-
Since: ArcGIS Maps SDK for JavaScript 4.23ActiveLayerInfo since 4.11, sublayerIds added at 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 2 activeLayerInfo.sublayerIds = [1, 2];
-
view
view View
-
The view in which the Legend is rendered.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
Type Definitions
-
Describes the schema of the ColorRampElement used as a legendElement. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
color-ramp
.The title of the color ramp as displayed in the legend.
infos ColorRampStop[]The individual color stops rendered in the legend that correspond to the color visual variable in the renderer.
-
Describes the schema of the ColorRampStop element. Each ColorRampStop represents a single stop of the ColorVariable referenced in the renderer.
- Properties
-
label String
The label in the legend describing features with the given
color
andvalue
.value NumberThe value of the color visual variable stop.
color ColorThe color of the visual variable stop.
offset NumberA number between
0
and1
describing the position of the label on the color ramp. For example, in a color ramp with three stops, the first stop would have an offset of0
, the second0.5
, and the third1
. These offsets are equally spaced for any given number of labels in the color ramp. The interval of each offset value is equal to 1 divided by the number of stops minus 1.
-
Describes the schema of the HeatmapRampElement used as a legendElement. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
heatmap-ramp
.optional The title of the heatmap ramp as displayed in the legend.
infos HeatmapRampStop[]The individual color stops rendered in the legend that correspond to the heatmap colorStops in the renderer.
-
Describes the schema of the HeatmapRampStop element. Each HeatmapRampStop represents a single
colorStop
of the Heatmap color stops referenced in the renderer.- Properties
-
label String
The label of the color stop displayed in the legend. Typically only the first and last stops have labels.
ratio NumberThe ratio of a pixel's intensity value to the minPixelIntensity of the renderer. The ratio of each pixel is matched to the corresponding color.
color ColorThe color of the pixel corresponding to the appropriate pixel
ratio
. This value is typically between0
and1
.offset NumberA number between
0
and1
describing the position of the label on the ramp. For example, in a ramp with three stops, the first stop would have an offset of0
, the second0.5
, and the third1
. These offset values are equally spaced for any given number of labels in the ramp. The interval of each offset value is equal to 1 divided by the number of stops minus 1.
-
Properties defining the scheme of each of the ImageSymbolTableElementInfo. This applies only to ImageryLayer renderers.
- Properties
-
label String
The label of the category corresponding to the given image.
src StringThe data URI of the image representing a colored pixel in the renderer.
opacity NumberThe opacity of the image (
0
to1
).width NumberThe width of the image in pixels.
height NumberThe height of the image in pixels.
-
LegendElement
LegendElement SymbolTableElement |ColorRampElement |OpacityRampElement |SizeRampElement |HeatmapRampElement |RelationshipRampElement
-
Properties defining the scheme of each of the supported legendElements.
-
Describes the schema of the OpacityRampElement used as a legendElement. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
opacity-ramp
.optional The title of the opacity ramp as displayed in the legend.
infos OpacityRampStop[]The individual opacity stops rendered in the legend that correspond to the opacity visual variable in the renderer.
-
Describes the schema of the OpacityRampStop element. Each OpacityRampStop represents a single stop of the OpacityVariable referenced in the renderer. The opacity value of each stop is indicated in the alpha property of the
color
object.- Properties
-
label String
The label in the legend describing features with the given
color
andvalue
.value NumberThe value of the opacity visual variable stop.
color ColorThe color of the visual variable stop. The opacity corresponding to the given
value
is indicated in the alpha property of the color object.offset NumberA number between
0
and1
describing the position of the label on the ramp. For example, in a ramp with three stops, the first stop would have an offset of0
, the second0.5
, and the third1
. These offsets are equally spaced for any given number of labels in the ramp. The interval of each offset value is equal to 1 divided by the number of stops minus 1.
-
Describes the schema of the RampTitle element.
- Properties
-
field String
The field name used in a visual variable of a renderer. This is used in the generated title of the corresponding ramp in the legend.
normField StringIf provided, the normalization field name used in a visual variable of a renderer. This is used in the generated title of the corresponding ramp in the legend.
ratio BooleanIf
true
, the legend formats to display the field and normalization field as a ratio.ratioPercent BooleanIf
true
, the legend formats to display the field and normalization field as a percentage.ratioPercentTotal BooleanIf
true
, the legend formats to display the field and normalization field as a percentage of total.
-
Describes the schema of the RelationshipLabels element. These labels are rendered in the corners of the square that represent the relationship renderer in the legend.
- Properties
-
top String
The label corresponding with the top corner of the legend if the focus is set to
HH
. This describes values that are considered high in both field 1 and field 2 (HH).bottom StringThe label corresponding with the bottom corner of the legend if the focus is set to
HH
. This describes values that are considered low in both field 1 and field 2 (LL).left StringThe label corresponding with the left corner of the legend (if the focus is set to
HH
). This describes features where the value of field 1 is high and the value of field 2 is low (HL).right StringThe label corresponding with the right corner of the legend (if the focus is set to
HH
). This describes features where the value of field 2 is high and the value of field 1 is low (LH).
-
Describes the schema of the RelationshipRampElement used as a legendElement. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
relationship-ramp
.numClasses NumberThe number of classes for each field comprising the renderer. Can either be 2, 3, or 4.
focus StringDetermines the orientation of the Legend. Values can be
HH
,HL
,LH
,LL
.A 2-dimensional array of colors as displayed in the legend grid.
labels RelationshipLabelsThe labels for each corner of the legend.
rotation NumberThe rotation of the legend in degrees (0-360).
0
degrees displays the legend as a square with theLL
cell in the bottom left corner of the legend and theHH
cell in the top right corner.title StringThe title of the renderer as displayed in the legend.
optional Info objects associated with the relationship renderer.
-
Describes the schema of the RendererTitle element.
- Properties
-
title String
The title of the renderer as displayed in the legend.
field StringThe field name used in the renderer. This is used in the generated title of the renderer in the legend.
normField StringIf a normalization field is provided to the renderer, this field is also used in the generated title for the renderer in the legend.
normByPct BooleanIndicates if a percentage is used in the normalization of the renderer. This is used to create a more readable legend for that scenario.
-
Describes the schema of the SizeRampElement used as a legendElement. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
size-ramp
.optional The title of the size ramp as displayed in the legend.
infos SizeRampStop[]The individual size stops rendered in the legend that correspond to the size visual variable in the renderer.
-
Describes the schema of the SizeRampStop element. Each SizeRampStop represents a single stop of the SizeVariable referenced in the renderer.
- Properties
-
label String
The label in the legend describing features with the given
symbol
andvalue
.value *The value of the size visual variable stop.
symbol SymbolThe symbol corresponding to the value of the stop in the renderer.
size NumberThe size of the visual variable stop in points.
outlineSize NumberThe width of the outline in points.
preview HTMLElementThe HTML element rendered in the legend representing features with the given value.
-
Describes the schema of the SymbolTableElement used as a legendElement. This legend element is used for UniqueValueRenderer and ClassBreaksRenderer. See the table below for more details of the properties in this object.
- Properties
-
type String
The type of this element is always
symbol-table
.title String|RendererTitleThe title of the renderer as displayed in the legend.
legendType StringOnly used for renderers set to ImageryLayers. Indicates the type of renderer set on the layer (e.g.
stretched
orUnique Values
).infos SymbolTableElementType[]An array of each symbol/category/break rendered for the symbol table. For example, this may be individual breaks for a ClassBreaksRenderer, or unique values for a UniqueValueRenderer.
-
Properties defining the scheme of the SymbolTableElementInfo.
- Properties
-
The title of the renderer as displayed in the Legend.
value *The value corresponding with the given
symbol
in the legend.symbol SymbolThe symbol for the corresponding
value
in the legend.size NumberThe size of the symbol in points.
preview HTMLElementA preview of the symbol element as displayed in the legend.
-
SymbolTableElementType
SymbolTableElementType ImageSymbolTableElementInfo |SymbolTableElementInfo
-
Properties defining the scheme of each SymbolTableElementType.