ActiveLayerInfo

AMD: require(["esri/widgets/Legend/support/ActiveLayerInfo"], (ActiveLayerInfo) => { /* code goes here */ });
ESM: import ActiveLayerInfo from "@arcgis/core/widgets/Legend/support/ActiveLayerInfo";
Class: esri/widgets/Legend/support/ActiveLayerInfo
Inheritance: ActiveLayerInfo Accessor
Since: ArcGIS API 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
Collection<ActiveLayerInfo>more details

A collection of child activeLayerInfos.

more detailsActiveLayerInfo
Stringmore details

The name of the class.

more detailsAccessor
Booleanmore details

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

more detailsActiveLayerInfo
Booleanmore details

Indicates if the legend's display of the layer's renderer is driven by the scale of the view.

more detailsActiveLayerInfo
Layermore details

The layer represented by the ActiveLayerInfo object.

more detailsActiveLayerInfo
LayerViewmore details

The layerView represented by the ActiveLayerInfo object's layer.

more detailsActiveLayerInfo
LegendElement[]more details

The legendElements is constructed using the layer Renderer.

more detailsActiveLayerInfo
Numbermore details

The opacity of the layer or parent element.

more detailsActiveLayerInfo
ActiveLayerInfomore details

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

more detailsActiveLayerInfo
Booleanmore details

Indicates if the activeLayerInfo is ready.

more detailsActiveLayerInfo
Booleanmore details

Determines whether to respect the properties of the layers in the map that control the legend's visibility (minScale, maxScale, legendEnabled).

more detailsActiveLayerInfo
Numbermore details

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

more detailsActiveLayerInfo
Stringmore details

The text string that represents the legend's title.

more detailsActiveLayerInfo
Numbermore details

The version of the ActiveLayerInfo.

more detailsActiveLayerInfo
Viewmore details

The view in which the Legend is rendered.

more detailsActiveLayerInfo

Property Details

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

declaredClass Stringreadonly inherited

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

hideLayersNotInCurrentView Boolean
Since: ArcGIS API 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.

Default Value:false
See also:
Example:
// layers not displayed in the view
// will not be shown in the legend
legend.hideLayersNotInCurrentView = true;
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

The layer represented by the ActiveLayerInfo object.

layerView LayerView

The layerView represented by the ActiveLayerInfo object's layer.

legendElements LegendElement[]

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

opacity Numberreadonly
Since: ArcGIS API for JavaScript 4.17

The opacity of the layer or parent element.

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

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 Boolean
Since: ArcGIS API 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 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 Number

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

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 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 View

The view in which the Legend is rendered.

Type Definitions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

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.