ActiveLayerInfo

AMD: require(["esri/widgets/Legend/support/ActiveLayerInfo"], (ActiveLayerInfo) => { /* code goes here */ });
ESM: import ActiveLayerInfo from "@arcgis/core/widgets/Legend/support/ActiveLayerInfo.js";
Class: esri/widgets/Legend/support/ActiveLayerInfo
Inheritance: ActiveLayerInfo Accessor
Since: ArcGIS Maps SDK for JavaScript 4.11

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

Any properties can be set, retrieved or listened to. See the Working with Properties topic.
Show inherited properties Hide inherited properties
Name Type Summary Class

A collection of child activeLayerInfos.

ActiveLayerInfo

The name of the class.

Accessor

When true, layers will only be shown in the legend if they are visible in the view's extent.

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 (minScale, maxScale, legendEnabled).

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

Property
children Collection<ActiveLayerInfo>

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

declaredClass

Inherited
Property
declaredClass Stringreadonly
Inherited from Accessor

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

hideLayersNotInCurrentView

Property
hideLayersNotInCurrentView Boolean
Since: ArcGIS Maps SDK for JavaScript 4.21 ActiveLayerInfo 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 to false.

Default Value:false
See also
Example
// layers not displayed in the view
// will not be shown in the legend
legend.hideLayersNotInCurrentView = true;

isScaleDriven

Property
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

Property
layer Layer

The layer represented by the ActiveLayerInfo object.

layerView

Property
layerView LayerView

The layerView represented by the ActiveLayerInfo object's layer.

legendElements

Property
legendElements LegendElement[]

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

opacity

Property
opacity Numberreadonly
Since: ArcGIS Maps SDK for JavaScript 4.17 ActiveLayerInfo since 4.11, opacity added at 4.17.

The opacity of the layer or parent element.

parent

Property
parent ActiveLayerInfo

The ActiveLayerInfo of the parent esri/layers/support/ISublayer or GroupLayer.

ready

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

Property
respectLayerVisibility Boolean
Since: ArcGIS Maps SDK for JavaScript 4.13 ActiveLayerInfo 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 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.

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;

scale

Property
scale Number

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

sublayerIds

Property
sublayerIds Number[]
Since: ArcGIS Maps SDK for JavaScript 4.23 ActiveLayerInfo 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];

title

Property
title String

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 title of the layer.

version

Property
version 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
view View

The view in which the Legend is rendered.

Method Overview

Show inherited methods Hide inherited methods
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

addHandles

Inherited
Method
addHandles(handleOrHandles, groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor 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();
Parameters
handleOrHandles WatchHandle|WatchHandle[]

Handles marked for removal once the object is destroyed.

groupKey *
optional

Key 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

Inherited
Method
hasHandles(groupKey){Boolean}
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, hasHandles added at 4.25.

Returns true if a named group of handles exist.

Parameter
groupKey *
optional

A group key.

Returns
Type 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");
}

removeHandles

Inherited
Method
removeHandles(groupKey)
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25 Accessor since 4.0, removeHandles added at 4.25.

Removes a group of handles owned by the object.

Parameter
groupKey *
optional

A group key or an array or collection of group keys to remove.

Example
obj.removeHandles(); // removes handles from default group

obj.removeHandles("handle-group");
obj.removeHandles("other-handle-group");

Type Definitions

ColorRampElement

Type Definition
ColorRampElement

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.

The individual color stops rendered in the legend that correspond to the color visual variable in the renderer.

ColorRampStop

Type Definition
ColorRampStop

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 and value.

value Number

The value of the color visual variable stop.

color Color

The color of the visual variable stop.

offset Number

A number between 0 and 1 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 of 0, the second 0.5, and the third 1. 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.

HeatmapRampElement

Type Definition
HeatmapRampElement

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.

The individual color stops rendered in the legend that correspond to the heatmap colorStops in the renderer.

HeatmapRampStop

Type Definition
HeatmapRampStop

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 Number

The 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 Color

The color of the pixel corresponding to the appropriate pixel ratio. This value is typically between 0 and 1.

offset Number

A number between 0 and 1 describing the position of the label on the ramp. For example, in a ramp with three stops, the first stop would have an offset of 0, the second 0.5, and the third 1. 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.

ImageSymbolTableElementInfo

Type Definition
ImageSymbolTableElementInfo

Properties defining the scheme of each of the ImageSymbolTableElementInfo. This applies only to ImageryLayer renderers.

Properties
label String
optional

The label of the category corresponding to the given image.

src String

The data URI of the image representing a colored pixel in the renderer.

opacity Number

The opacity of the image (0 to 1).

width Number
optional

The width of the image in pixels.

height Number
optional

The height of the image in pixels.

Properties defining the scheme of each of the supported legendElements.

OpacityRampElement

Type Definition
OpacityRampElement

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.

The individual opacity stops rendered in the legend that correspond to the opacity visual variable in the renderer.

OpacityRampStop

Type Definition
OpacityRampStop

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 and value.

value Number

The value of the opacity visual variable stop.

color Color

The color of the visual variable stop. The opacity corresponding to the given value is indicated in the alpha property of the color object.

offset Number

A number between 0 and 1 describing the position of the label on the ramp. For example, in a ramp with three stops, the first stop would have an offset of 0, the second 0.5, and the third 1. 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.

RampTitle

Type Definition
RampTitle

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 String

If 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 Boolean

If true, the legend formats to display the field and normalization field as a ratio.

ratioPercent Boolean

If true, the legend formats to display the field and normalization field as a percentage.

ratioPercentTotal Boolean

If true, the legend formats to display the field and normalization field as a percentage of total.

RelationshipLabels

Type Definition
RelationshipLabels

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 String

The 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 String

The 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 String

The 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).

RelationshipRampElement

Type Definition
RelationshipRampElement

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 Number

The number of classes for each field comprising the renderer. Can either be 2, 3, or 4.

focus String

Determines the orientation of the Legend. Values can be HH, HL, LH, LL.

colors Color[][]

A 2-dimensional array of colors as displayed in the legend grid.

The labels for each corner of the legend.

rotation Number

The rotation of the legend in degrees (0-360). 0 degrees displays the legend as a square with the LL cell in the bottom left corner of the legend and the HH cell in the top right corner.

title String
optional

The title of the renderer as displayed in the legend.

infos Object[]
optional

Info objects associated with the relationship renderer.

RendererTitle

Type Definition
RendererTitle

Describes the schema of the RendererTitle element.

Properties
title String
optional

The title of the renderer as displayed in the legend.

field String

The field name used in the renderer. This is used in the generated title of the renderer in the legend.

normField String

If a normalization field is provided to the renderer, this field is also used in the generated title for the renderer in the legend.

normByPct Boolean

Indicates if a percentage is used in the normalization of the renderer. This is used to create a more readable legend for that scenario.

SizeRampElement

Type Definition
SizeRampElement

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.

The individual size stops rendered in the legend that correspond to the size visual variable in the renderer.

SizeRampStop

Type Definition
SizeRampStop

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 and value.

value *
optional

The value of the size visual variable stop.

symbol Symbol

The symbol corresponding to the value of the stop in the renderer.

size Number
optional

The size of the visual variable stop in points.

outlineSize Number
optional

The width of the outline in points.

preview HTMLElement
optional

The HTML element rendered in the legend representing features with the given value.

SymbolTableElement

Type Definition
SymbolTableElement

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.

optional

The title of the renderer as displayed in the legend.

legendType String
optional

Only used for renderers set to ImageryLayers. Indicates the type of renderer set on the layer (e.g. stretched or Unique Values).

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.

SymbolTableElementInfo

Type Definition
SymbolTableElementInfo

Properties defining the scheme of the SymbolTableElementInfo.

Properties

The title of the renderer as displayed in the Legend.

value *
optional

The value corresponding with the given symbol in the legend.

symbol Symbol

The symbol for the corresponding value in the legend.

size Number
optional

The size of the symbol in points.

preview HTMLElement
optional

A preview of the symbol element as displayed in the legend.

SymbolTableElementType

Type Definition
SymbolTableElementType ImageSymbolTableElementInfo |SymbolTableElementInfo

Properties defining the scheme of each SymbolTableElementType.

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.