UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

131 lines (129 loc) 7.62 kB
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 { MapViewOrSceneView } from "../../../views/MapViewOrSceneView.js"; import type { LegendElement } from "../../types.js"; export interface ActiveLayerInfoProperties extends Partial<Pick<ActiveLayerInfo, "children" | "hideLayersNotInCurrentView" | "layer" | "layerView" | "legendElements" | "parent" | "respectLayerVisibility" | "sublayerIds" | "title" | "view">> {} /** * ActiveLayerInfo is added to or removed from the collection of * [Legend.activeLayerInfos](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/#activeLayerInfos) as layers become visible or * invisible in the view. You can use this module to make the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-legend/) more interactive. * * @since 4.11 */ 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<ActiveLayerInfo>; /** * The CSS filter string for the effects of the active layer. * * @since 4.34 */ 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 * @since 4.21 * @see [respectLayerVisibility](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/#respectLayerVisibility) * @example * // layers not displayed in the view * // will not be shown in the legend * legend.hideLayersNotInCurrentView = true; */ 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; /** 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[]; /** * The opacity of the layer or parent element. * * @since 4.17 */ 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/widgets/Legend/support/ActiveLayerInfo/#legendElements) are computed. * It is set to `false` when the layer renderer changes so that the legendElements can recomputed. */ get ready(): 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 * @since 4.13 * @see [hideLayersNotInCurrentView](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/ActiveLayerInfo/#hideLayersNotInCurrentView) * @example * // Always displays legend elements for the map's layers * // regardless of their minScale, maxScale, and legendEnabled properties * legend.respectLayerVisibility = false; */ accessor respectLayerVisibility: boolean; /** The scale of the view instance in which the Legend is rendered. */ get scale(): number; /** * Only applies if the [layer](https://developers.arcgis.com/javascript/latest/references/core/widgets/Legend/support/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. * * @since 4.23 * @example * // Only displays legend items for sublayers 1 and 2 * activeLayerInfo.sublayerIds = [1, 2]; */ 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/widgets/Legend/support/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; }