import type Accessor from "../core/Accessor.js"; import type Collection from "../core/Collection.js"; import type Layer from "../layers/Layer.js"; import type LayerView from "../views/layers/LayerView.js"; import type { LegendElement } from "./types.js"; import type { MapViewOrSceneView } from "../views/MapViewOrSceneView.js"; export interface ActiveLayerInfoProperties extends Partial> {} /** * Represents the legend content for a layer or sublayer in a * [LegendModel](https://developers.arcgis.com/javascript/latest/references/core/legend/LegendModel/) instance. * * An `ActiveLayerInfo` is added to or removed from * [LegendModel.activeLayerInfos](https://developers.arcgis.com/javascript/latest/references/core/legend/LegendModel/#activeLayerInfos) as layers become visible or invisible in the view. It maintains * parent and child relationships and generates the [legend elements](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements) * required to render the layer's symbology. * * You can use this class to build custom, interactive legends without using the * [Legend component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/). * * @since 5.2 */ export default class ActiveLayerInfo extends Accessor { constructor(properties?: ActiveLayerInfoProperties); /** * A collection of child activeLayerInfos. This only applies to renderers of * [Sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/) or the children * of [GroupLayers](https://developers.arcgis.com/javascript/latest/references/core/layers/GroupLayer/). */ accessor children: Collection; /** The CSS filter string representing the effects applied to the active layer. */ get cssEffectFilter(): string | null | undefined; /** * 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 false * @see [respectLayerVisibility](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#respectLayerVisibility) */ accessor hideLayersNotInCurrentView: 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](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/) renderers, any renderer that uses * a `valueExpression` (Arcade expression), [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/DotDensityRenderer/), and * layers that have [FeatureReductionLayer.featureReduction](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/FeatureReductionLayer/#featureReduction) enabled. */ get isScaleDriven(): 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 false */ accessor keepCacheOnDestroy: boolean; /** The layer represented by the ActiveLayerInfo object. */ accessor layer: Layer; /** The layerView represented by the ActiveLayerInfo object's layer. */ accessor layerView: LayerView; /** * The legendElements is constructed using the layer [Renderer](https://developers.arcgis.com/javascript/latest/references/core/renderers/Renderer/). It reflects the actual * structure of the legend. */ accessor legendElements: LegendElement[]; /** Indicates whether legend elements are currently being generated for this layer or its children. */ get loading(): boolean; /** The opacity of the layer or parent element. */ get opacity(): number; /** The ActiveLayerInfo of the parent [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/Sublayer/) or [GroupLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GroupLayer/). */ accessor parent: ActiveLayerInfo | null | undefined; /** * Indicates if the activeLayerInfo is ready. It is set to `true` when all its [legendElements](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#legendElements) are computed. * It is set to `false` when the layer renderer changes so that the legendElements can recomputed. */ get ready(): boolean; /** * Indicates whether the layer's definition expression should be applied when generating legend information. * * @default false */ accessor respectLayerDefinitionExpression: 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: * * - The [FeatureLayer.legendEnabled](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/#legendEnabled) property * is set to `false`. * - If the view's scale is outside the visibility range * defined by the [ScaleRangeLayer.minScale](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ScaleRangeLayer/#minScale) and * [ScaleRangeLayer.maxScale](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/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. * * @default true * @see [hideLayersNotInCurrentView](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#hideLayersNotInCurrentView) */ accessor respectLayerVisibility: boolean; /** * The scale of the view instance in which the Legend is rendered. * * @default 0 */ get scale(): number; /** * Only applies if the [layer](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#layer) is a [MapImageLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MapImageLayer/). An array of * MapImageLayer [Sublayer](https://developers.arcgis.com/javascript/latest/references/core/layers/support/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. */ accessor sublayerIds: number[]; /** * 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](https://developers.arcgis.com/javascript/latest/references/core/layers/Layer/#title). */ accessor title: string | null | undefined; /** * The version of the ActiveLayerInfo. It increases by `1` whenever [ready](https://developers.arcgis.com/javascript/latest/references/core/legend/ActiveLayerInfo/#ready) property of ActiveLayerInfo changes. * This property should watched in the view for ActiveLayerInfo changes and update the DOM accordingly. */ get version(): number; /** The view in which the Legend is rendered. */ accessor view: MapViewOrSceneView; }