import { EventSource } from "@conterra/reactivity-events"; import { MapModel } from "../model/MapModel"; import { GroupLayerCollection } from "./group/GroupLayerCollection"; import { GroupLayer } from "./GroupLayer"; import { ChildrenCollection } from "./shared/ChildrenCollection"; import { ATTACH_TO_GROUP, ATTACH_TO_MAP, DETACH_FROM_GROUP, DETACH_FROM_MAP } from "./shared/internals"; import { SublayersCollection } from "./shared/SublayersCollection"; import { AnyLayer, AnyLayerTypes, Sublayer } from "./unions"; export interface AbstractLayerBaseOptions { id?: string; title: string; description?: string; attributes?: Record; internal?: boolean; } /** * Interface shared by all layer types (operational layers and sublayers). * * Instances of this interface cannot be constructed directly; use a real layer * class such as {@link SimpleLayer} instead. * * @group Layers */ export declare abstract class AbstractLayerBase { #private; constructor(config: AbstractLayerBaseOptions); /** * Destroys the layer and everything owned by it. * * > NOTE: Layers that are part of the map will be destroyed automatically * > when that map is being destroyed. */ destroy(): void; /** True if the layer has been destroyed. */ get isDestroyed(): boolean; /** * Emits an event when the layer is destroyed. */ get destroyed(): EventSource; /** * The unique id of this layer within its map model. * * NOTE: layer ids may not be globally unique: layers that belong * to different map models may have the same id. */ get id(): string; /** The human-readable title of this layer. */ get title(): string; /** The human-readable description of this layer. May be empty. */ get description(): string; /** * Property that specifies if the layer is an "internal" layer. Internal layers are not considered by any UI widget (e.g. Toc or Legend). * The internal state is independent of the layer's visibility which is determined by {@link visible} * * NOTE: Some UI widgets might use component specific attributes or props that have precedence over the internal property. */ get internal(): boolean; /** * Additional attributes associated with this layer. * * NOTE: Do not modify vis this getter. * Use {@link updateAttributes} or {@link deleteAttribute} instead. */ get attributes(): Record; /** * The map this layer belongs to. * * NOTE: Throws if the layer is not part of a map. */ get map(): MapModel; /** * The map this layer belongs to, or undefined if the layer is not part of a map. */ get nullableMap(): MapModel | undefined; /** * The direct parent of this layer instance, used for sublayers or for layers in a group layer. * * The property shall be undefined if the layer is not a sublayer or member of a group layer. */ get parent(): AnyLayer | undefined; /** * The direct children of this layer. * * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`. * * See also {@link layers} and {@link sublayers}. */ get children(): ChildrenCollection | undefined; /** * Identifies the type of this layer. */ abstract get type(): AnyLayerTypes; /** * Whether the layer is visible or not. * * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property. * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances. */ abstract get visible(): boolean; /** * If this layer is a group layer this property contains a collection of all layers that are members of the group. * * The property shall be `undefined` if it is not a group layer. * * The properties `layers` and `sublayers` are mutually exclusive. */ abstract get layers(): GroupLayerCollection | undefined; /** * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer. * * Layers that can never have any sublayers may not have a `sublayers` collection. * * The properties `layers` and `sublayers` are mutually exclusive. */ abstract get sublayers(): SublayersCollection | undefined; /** * Legend URL from the service capabilities, if available. * * Note: this property may be expanded upon in the future, e.g. to support more variants than just image URLs. */ abstract get legend(): string | undefined; /** * Attaches the layer to its owning map. * * @internal */ [ATTACH_TO_MAP](map: MapModel): void; /** * Attach group layers to its parent group layer. * Called by the parent layer. * * @internal */ [ATTACH_TO_GROUP](parent: GroupLayer): void; /** * Called when a layer is removed from the map. * * @internal */ [DETACH_FROM_MAP](): void; /** * Detach layer from parent group layer. * * Called by the parent group layer when destroyed or the layer gets removed. * * @internal */ [DETACH_FROM_GROUP](): void; /** * Updates the title of this layer. */ setTitle(newTitle: string): void; /** * Updates the description of this layer. */ setDescription(newDescription: string): void; /** * Updates the internal property of this layer to the new value. */ setInternal(newIsInternal: boolean): void; /** * Updates the attributes of this layer. * Values in `newAttributes` will override existing values with the same key. */ updateAttributes(newAttributes: Record): void; /** * Deletes the attribute of this layer. */ deleteAttribute(deleteAttribute: string | symbol): void; /** * Updates the visibility of this layer to the new value. * * NOTE: The visibility of base layers cannot be changed through this method. * Call {@link LayerCollection.activateBaseLayer} instead. */ abstract setVisible(newVisibility: boolean): void; }