@open-pioneer/map 1.4.0 → 1.5.0-dev.20260910103330

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"LayerCollection.js","sources":["LayerCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n batch,\n effect,\n reactive,\n ReactiveArray,\n reactiveArray,\n reactiveMap,\n reactiveSet\n} from \"@conterra/reactivity-core\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { AbstractLayer } from \"../layers/AbstractLayer\";\nimport { AbstractLayerBase } from \"../layers/AbstractLayerBase\";\nimport type { AddLayerOptions } from \"../layers/shared/AddLayerOptions\";\nimport { getRecursiveLayers } from \"../layers/shared/getRecursiveLayers\";\nimport {\n ATTACH_TO_MAP,\n DETACH_FROM_MAP,\n GET_RAW_LAYERS,\n GET_RAW_SUBLAYERS,\n SET_VISIBLE\n} from \"../layers/shared/internals\";\nimport type {\n LayerRetrievalOptions,\n RecursiveRetrievalOptions\n} from \"../layers/shared/LayerRetrievalOptions\";\nimport { AnyLayer, Layer, Sublayer } from \"../layers/unions\";\nimport { assertInternalConstructor, InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { MapModel } from \"./MapModel\";\n\nconst LOG = createLogger(sourceId);\n\ntype LayerType = AbstractLayer & Layer;\ntype LayerBaseType = (AbstractLayerBase & Layer) | (AbstractLayerBase & Sublayer);\n\ninterface OpOrTopmostLayerPos {\n which: \"normal\" | \"topmost\";\n index: number;\n}\n\ninterface BaseLayerPos {\n which: \"base\";\n}\n\ntype LayerPos = OpOrTopmostLayerPos | BaseLayerPos;\n\n/**\n * Contains the layers contained in a {@link MapModel}.\n *\n * @group Map Model\n */\nexport class LayerCollection {\n #map: MapModel;\n\n /** Top level layers (base layers, operational layers). No sublayers. */\n #topLevelLayers = reactiveSet<LayerType>();\n\n /** Index of _all_ layer instances, including sublayers. */\n #layersById = reactiveMap<string, LayerBaseType>();\n\n /** Reverse index of _all_ layers that have an associated OpenLayers layer. */\n #layersByOlLayer: WeakMap<OlBaseLayer, LayerType> = new WeakMap();\n\n /** Currently active base layer. */\n #activeBaseLayer = reactive<LayerType>();\n\n /**\n * Defines the relative order of operational layers.\n * Lower index -> layer is below its successors.\n * Excluding {@link #topMostOperationalLayers}\n */\n #operationalLayerOrder = reactiveArray<LayerType>();\n\n /** Operational layers that are always displayed at the top above all other layers (e.g. a highlight layer) */\n #topMostOperationalLayers = reactiveArray<LayerType>();\n\n #syncHandle: Resource | undefined;\n\n /** @internal */\n constructor(map: MapModel, tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n\n this.#map = map;\n this.#syncHandle = effect(() => {\n // Contains base layers, normal operational layers, topmost layers in bottom-to-top order.\n const orderedLayers = this.getLayers({\n sortByDisplayOrder: true,\n includeInternalLayers: true\n });\n\n // Simply reassign all z-indices whenever the order changes.\n let index = 0;\n for (const layer of orderedLayers) {\n LOG.isDebug() && LOG.debug(\"Assigning z-index\", layer.id, index);\n layer.olLayer.setZIndex(index);\n index++;\n }\n });\n }\n\n destroy() {\n for (const layer of this.#layersById.values()) {\n layer.destroy();\n }\n this.#topLevelLayers.clear();\n this.#layersById.clear();\n this.#operationalLayerOrder.splice(0, this.#operationalLayerOrder.length);\n this.#activeBaseLayer.value = undefined;\n this.#syncHandle?.destroy();\n this.#syncHandle = undefined;\n }\n\n /**\n * Adds a new layer to the map.\n *\n * The new layer is automatically registered with this collection.\n *\n * ### Display order\n *\n * By default, the new layer will be shown on _top_ of all normal operational layers.\n * Use the `options` parameter to control the insertion point.\n *\n * ### Ownership\n *\n * The map model takes ownership of the new layer.\n * This means that the layer will be destroyed if the map model is destroyed.\n */\n addLayer(layer: Layer, options?: AddLayerOptions): void {\n batch(() => {\n checkLayerInstance(layer);\n\n layer[ATTACH_TO_MAP](this.#map);\n this.#addLayer(layer, options);\n });\n }\n\n /**\n * Returns all configured base layers.\n */\n getBaseLayers(): Layer[] {\n // Slightly inefficient, but we don't need a separate index for base layers right now.\n return Array.from(this.#topLevelLayers).filter((layer) => layer.isBaseLayer);\n }\n\n /**\n * Returns the currently active base layer.\n */\n getActiveBaseLayer(): Layer | undefined {\n return this.#activeBaseLayer.value;\n }\n\n /**\n * Activates the base layer with the given id.\n * `undefined` can be used to hide all base layers.\n *\n * The associated layer is made visible and all other base layers are hidden.\n *\n * Returns true if the given layer has been successfully activated.\n */\n activateBaseLayer(id: string | undefined): boolean {\n let newBaseLayer = undefined;\n if (id != null) {\n newBaseLayer = this.#layersById.get(id);\n if (!newBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is unknown.`);\n return false;\n }\n if (!(newBaseLayer instanceof AbstractLayer)) {\n LOG.warn(`Cannot activate base layer '${id}: layer has an invalid type.'`);\n return false;\n }\n if (!newBaseLayer.isBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is not a base layer.`);\n return false;\n }\n }\n\n this.#updateBaseLayer(newBaseLayer);\n return true;\n }\n\n /**\n * Returns a list of operational layers, starting from the root of the map's layer hierarchy.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n */\n getOperationalLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options).filter((layer) => !layer.isBaseLayer);\n }\n\n /**\n * Returns a list of layers known to this collection. This includes base layers and operational layers.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n */\n getLayers(options?: LayerRetrievalOptions): Layer[] {\n let allLayers: Layer[];\n\n if (options?.sortByDisplayOrder) {\n const baseLayers = this.getBaseLayers();\n const order = Array.from(this.#operationalLayerOrder);\n const topMost = Array.from(this.#topMostOperationalLayers);\n allLayers = [...baseLayers, ...order, ...topMost];\n } else {\n allLayers = Array.from(this.#topLevelLayers.values());\n }\n\n if (!options?.includeInternalLayers) {\n allLayers = allLayers.filter((l) => !l.internal);\n }\n return allLayers;\n }\n\n /**\n * Returns a list of layers known to this collection. This includes base layers and operational layers.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n *\n * @deprecated Use {@link getLayers()}, {@link getOperationalLayers()} or {@link getRecursiveLayers()} instead.\n * This method name is misleading since it does not recurse into child layers.\n */\n getAllLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n /**\n * Returns a list of all layers in this collection, including all children (recursively).\n *\n * > Note: This includes base layers by default (see `options.filter`).\n * > Use the `\"base\"` or `\"operational\"` short hand values to filter by base layer or operational layers.\n * >\n * > If the layer hierarchy is deeply nested, this function could potentially be expensive.\n */\n getRecursiveLayers({\n filter,\n sortByDisplayOrder,\n includeInternalLayers\n }: Omit<RecursiveRetrievalOptions, \"filter\"> & {\n filter?: \"base\" | \"operational\" | ((layer: AnyLayer) => boolean);\n } = {}): AnyLayer[] {\n let filterFunc;\n if (typeof filter === \"function\") {\n filterFunc = filter;\n } else if (typeof filter === \"string\") {\n const filterType = filter;\n const topLevelFilter = (layer: Layer) => {\n return filterType === \"base\" ? layer.isBaseLayer : !layer.isBaseLayer;\n };\n filterFunc = (layer: AnyLayer) => {\n if (!layer.parent && \"isBaseLayer\" in layer) {\n return topLevelFilter(layer);\n }\n // For nested children, include them all.\n return true;\n };\n }\n\n return getRecursiveLayers({\n from: this,\n filter: filterFunc,\n sortByDisplayOrder,\n includeInternalLayers\n });\n }\n\n getItems(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n /**\n * Returns the layer identified by the `id` or undefined, if no such layer exists.\n */\n getLayerById(id: string): AnyLayer | undefined {\n return this.#layersById.get(id);\n }\n\n /**\n * Removes a layer identified by the `id` from the map.\n *\n * NOTE: The current implementation only supports removal of _top level_ layers.\n *\n * ### Ownership\n *\n * This function _destroys_ the layer instance and all its children.\n *\n * @deprecated Use {@link removeLayer} instead.\n */\n removeLayerById(id: string): void {\n batch(() => {\n const layer = this.#layersById.get(id);\n if (!layer) {\n LOG.isDebug() && LOG.debug(`Cannot remove layer '${id}': layer is unknown.`);\n return;\n }\n\n checkLayerInstance(layer);\n if (!this.#topLevelLayers.has(layer)) {\n LOG.warn(\n `Cannot remove layer '${layer.id}': only top level layers can be removed at this time.`\n );\n return;\n }\n\n this.#removeLayer(layer);\n layer.destroy();\n });\n }\n\n /**\n * Removes the given top level layer from the map.\n *\n * The layer can be specified directly (as an object) or by an id.\n *\n * Returns the layer instance on success, or `undefined` if the layer was not found.\n *\n * ### Ownership\n *\n * The map releases ownership of this layer.\n * The caller can destroy it or store it for later reuse.\n */\n removeLayer(layer: string | Layer): Layer | undefined {\n return batch(() => {\n let actualLayer;\n if (typeof layer === \"string\") {\n actualLayer = this.#layersById.get(layer);\n if (!actualLayer) {\n return undefined;\n }\n } else {\n actualLayer = layer;\n }\n\n checkLayerInstance(actualLayer);\n if (!this.#topLevelLayers.has(actualLayer)) {\n return undefined;\n }\n\n this.#removeLayer(actualLayer);\n actualLayer[DETACH_FROM_MAP]();\n return actualLayer;\n });\n }\n\n /**\n * Given a raw OpenLayers layer instance, returns the associated {@link Layer} - or undefined\n * if the layer is unknown to this collection.\n */\n getLayerByRawInstance(layer: OlBaseLayer): Layer | undefined {\n return this.#layersByOlLayer?.get(layer);\n }\n\n /**\n * Adds the given layer to the map and all relevant indices.\n */\n #addLayer(layer: LayerType, options: AddLayerOptions | undefined) {\n // Throws; do this before manipulating the data structures\n const pos = this.#getInsertionPos(layer, options);\n this.#indexLayer(layer);\n\n // Everything below this line should not fail.\n if (pos.which === \"base\") {\n if (!this.#activeBaseLayer.value && layer.visible) {\n this.#updateBaseLayer(layer);\n } else {\n layer[SET_VISIBLE](false);\n }\n } else {\n layer[SET_VISIBLE](layer.visible);\n\n const layerList = this.#getLayerList(pos);\n layerList.splice(pos.index, 0, layer); // insert new layer at insertion index\n }\n this.#topLevelLayers.add(layer);\n this.#map.olMap.addLayer(layer.olLayer);\n }\n\n #getInsertionPos(layer: LayerType, options: AddLayerOptions | undefined): LayerPos {\n if (layer.isBaseLayer) {\n if (options?.at) {\n throw new Error(\n `Cannot add base layer '${layer.id}' at a specific position: only operational layers can be added at a specific position.`\n );\n }\n return { which: \"base\" };\n }\n\n switch (options?.at) {\n case undefined:\n case null:\n case \"top\":\n return { which: \"normal\", index: this.#operationalLayerOrder.length };\n case \"topmost\":\n return { which: \"topmost\", index: this.#topMostOperationalLayers.length };\n case \"bottom\":\n return { which: \"normal\", index: 0 };\n case \"above\":\n case \"below\": {\n const reference = this.#getReference(options.reference);\n const pos = this.#findOpOrTopmost(reference);\n if (!pos) {\n // reference is not a top level operational layer -> throw error\n const errorMessage = this.#getInsertErrorMessage(layer, reference);\n throw new Error(errorMessage);\n }\n\n if (options.at === \"above\") {\n pos.index++;\n }\n return pos;\n }\n }\n assertNever(options);\n }\n\n #getReference(reference: Layer | string): LayerType {\n let layer: AnyLayer;\n if (typeof reference === \"string\") {\n const refLayer = this.getLayerById(reference);\n if (!refLayer) {\n throw new Error(`Unknown reference layer '${reference}'.`);\n }\n layer = refLayer;\n } else {\n layer = reference;\n }\n checkLayerInstance(layer);\n return layer;\n }\n\n /**\n * Removes the given top level layer from the map and all relevant indices.\n */\n #removeLayer(layer: LayerType) {\n this.#map.olMap.removeLayer(layer.olLayer);\n this.#topLevelLayers.delete(layer);\n if (!layer.isBaseLayer) {\n const pos = this.#findOpOrTopmost(layer);\n if (!pos) {\n throw new Error(`Internal error: layer '${layer.id}' not found.`);\n }\n const layerList = this.#getLayerList(pos);\n layerList.splice(pos.index, 1);\n }\n\n this.#unIndexLayer(layer);\n if (this.#activeBaseLayer.value === layer) {\n const newBaseLayer = this.getBaseLayers()[0];\n if (newBaseLayer) {\n checkLayerInstance(newBaseLayer);\n }\n this.#updateBaseLayer(newBaseLayer);\n }\n }\n\n #updateBaseLayer(layer: LayerType | undefined) {\n if (this.#activeBaseLayer.value === layer) {\n return;\n }\n\n if (LOG.isDebug()) {\n const getId = (layer: AbstractLayer | undefined) => {\n return layer ? `'${layer.id}'` : undefined;\n };\n\n LOG.debug(\n `Switching active base layer from ${getId(this.#activeBaseLayer.value)} to ${getId(layer)}`\n );\n }\n\n batch(() => {\n this.#activeBaseLayer.value?.[SET_VISIBLE](false);\n this.#activeBaseLayer.value = layer;\n layer?.[SET_VISIBLE](true);\n });\n }\n\n /**\n * Index the layer and all its children.\n */\n #indexLayer(layer: LayerType) {\n // layer id -> layer (or sublayer)\n const registrations: [string, OlBaseLayer | undefined][] = [];\n const visit = (layer: LayerType | (AbstractLayerBase & Sublayer)) => {\n const id = layer.id;\n const olLayer = \"olLayer\" in layer ? layer.olLayer : undefined;\n if (this.#layersById.has(id)) {\n throw new Error(\n `Layer id '${id}' is not unique. Either assign a unique id yourself ` +\n `or skip configuring 'id' for an automatically generated id.`\n );\n }\n if (olLayer && this.#layersByOlLayer.has(olLayer)) {\n throw new Error(`OlLayer used by layer '${id}' has already been used in map.`);\n }\n\n // Register this layer with the map.\n this.#layersById.set(id, layer);\n if (olLayer) {\n this.#layersByOlLayer.set(olLayer, layer as LayerType); // ol is present --> not a sublayer\n }\n registrations.push([id, olLayer]);\n\n // Recurse into nested children.\n for (const childLayer of layer.layers?.[GET_RAW_LAYERS]() ?? []) {\n visit(childLayer);\n }\n for (const sublayer of layer.sublayers?.[GET_RAW_SUBLAYERS]() ?? []) {\n visit(sublayer);\n }\n };\n\n try {\n visit(layer);\n } catch (e) {\n // If any error happens, undo the indexing.\n // This way we don't leave a partially indexed layer tree behind.\n for (const [id, olLayer] of registrations) {\n this.#layersById.delete(id);\n if (olLayer) {\n this.#layersByOlLayer.delete(olLayer);\n }\n }\n throw e;\n }\n }\n\n /**\n * Removes index entries for the given layer and all its children.\n */\n #unIndexLayer(layer: AbstractLayer) {\n const visit = (layer: AbstractLayer | AbstractLayerBase) => {\n if (\"olLayer\" in layer) {\n this.#layersByOlLayer.delete(layer.olLayer);\n }\n this.#layersById.delete(layer.id);\n\n for (const childLayer of layer.layers?.[GET_RAW_LAYERS]() ?? []) {\n visit(childLayer);\n }\n\n for (const sublayer of layer.sublayers?.[GET_RAW_SUBLAYERS]() ?? []) {\n visit(sublayer);\n }\n };\n visit(layer);\n }\n\n #getLayerList(pos: OpOrTopmostLayerPos): ReactiveArray<LayerType> {\n switch (pos.which) {\n case \"topmost\":\n return this.#topMostOperationalLayers;\n case \"normal\":\n return this.#operationalLayerOrder;\n }\n }\n\n #findOpOrTopmost(layer: LayerType): OpOrTopmostLayerPos | undefined {\n let index = this.#operationalLayerOrder.indexOf(layer);\n if (index !== -1) {\n return { which: \"normal\", index };\n }\n\n index = this.#topMostOperationalLayers.indexOf(layer);\n if (index !== -1) {\n return { which: \"topmost\", index };\n }\n return undefined;\n }\n\n #getInsertErrorMessage(layer: LayerType, reference: LayerType) {\n let message: string = `Cannot add layer '${layer.id}'. Reference layer '${reference.id}' is not a top level operational layer.`;\n\n if (reference.isBaseLayer) {\n //is base layer\n message += \" Reference layer is a base layer.\";\n } else if (reference.parent) {\n //is child layer\n message += \" Reference layer is child layer of a group.\";\n }\n\n return message;\n }\n}\n\nfunction checkLayerInstance(object: AnyLayer): asserts object is Layer & AbstractLayer {\n if (!(object instanceof AbstractLayer)) {\n throw new Error(\n `Layer is not a valid layer instance. Use one of the classes provided by the map package instead.`\n );\n }\n}\n\nfunction assertNever(_arg: never): never {\n throw new Error(`Internal error: unhandled option.`);\n}\n"],"names":["layer"],"mappings":";;;;;;;;AAkCA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAqB1B,MAAM,eAAA,CAAgB;AAAA,EACzB,IAAA;AAAA;AAAA,EAGA,kBAAkB,WAAA,EAAuB;AAAA;AAAA,EAGzC,cAAc,WAAA,EAAmC;AAAA;AAAA,EAGjD,gBAAA,uBAAwD,OAAA,EAAQ;AAAA;AAAA,EAGhE,mBAAmB,QAAA,EAAoB;AAAA;AAAA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A,kBAAA,EAAqB,KAAA,CAAM,EAAE,CAAA,oBAAA,EAAuB,UAAU,EAAE,CAAA,uCAAA,CAAA;AAEtF,IAAA,IAAI,UAAU,WAAA,EAAa;AAEvB,MAAA,OAAA,IAAW,mCAAA;AAAA,IACf,CAAA,MAAA,IAAW,UAAU,MAAA,EAAQ;AAEzB,MAAA,OAAA,IAAW,6CAAA;AAAA,IACf;AAEA,IAAA,OAAO,OAAA;AAAA,EACX;AACJ;AAEA,SAAS,mBAAmB,MAAA,EAA2D;AACnF,EAAA,IAAI,EAAE,kBAAkB,aAAA,CAAA,EAAgB;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,gGAAA;AAAA,KACJ;AAAA,EACJ;AACJ;AAEA,SAAS,YAAY,IAAA,EAAoB;AACrC,EAAA,MAAM,IAAI,MAAM,CAAA,iCAAA,CAAmC,CAAA;AACvD;;;;"}
1
+ {"version":3,"file":"LayerCollection.js","sources":["LayerCollection.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n batch,\n effect,\n reactive,\n ReactiveArray,\n reactiveArray,\n reactiveMap,\n reactiveSet\n} from \"@conterra/reactivity-core\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { AbstractLayer } from \"../layers/AbstractLayer\";\nimport { AbstractLayerBase } from \"../layers/AbstractLayerBase\";\nimport type { AddLayerOptions } from \"../layers/shared/AddLayerOptions\";\nimport { getRecursiveLayers } from \"../layers/shared/getRecursiveLayers\";\nimport {\n ATTACH_TO_MAP,\n DECLARED_AS_BASE_LAYER,\n DETACH_FROM_MAP,\n GET_RAW_LAYERS,\n GET_RAW_SUBLAYERS,\n SET_VISIBLE\n} from \"../layers/shared/internals\";\nimport type {\n LayerRetrievalOptions,\n RecursiveRetrievalOptions\n} from \"../layers/shared/LayerRetrievalOptions\";\nimport { AnyLayer, Layer, Sublayer } from \"../layers/unions\";\nimport { assertInternalConstructor, InternalConstructorTag } from \"../utils/InternalConstructorTag\";\nimport { MapModel } from \"./MapModel\";\n\nconst LOG = createLogger(sourceId);\n\ntype LayerType = AbstractLayer & Layer;\ntype LayerBaseType = (AbstractLayerBase & Layer) | (AbstractLayerBase & Sublayer);\n\ninterface LayerPos {\n which: \"normal\" | \"topmost\" | \"base\";\n index: number;\n}\n\n/**\n * Contains the layers contained in a {@link MapModel}.\n *\n * @group Map Model\n */\nexport class LayerCollection {\n #map: MapModel;\n\n /** Top level layers (base layers, operational layers). No sublayers. */\n #topLevelLayers = reactiveSet<LayerType>();\n\n /** Index of _all_ layer instances, including sublayers. */\n #layersById = reactiveMap<string, LayerBaseType>();\n\n /** Reverse index of _all_ layers that have an associated OpenLayers layer. */\n #layersByOlLayer: WeakMap<OlBaseLayer, LayerType> = new WeakMap();\n\n /** Currently active base layer. */\n #activeBaseLayer = reactive<LayerType>();\n\n /**\n * Defines the relative order of operational layers.\n * Lower index -> layer is below its successors.\n * Excluding {@link #topMostOperationalLayers}\n */\n #operationalLayerOrder = reactiveArray<LayerType>();\n\n /** Operational layers that are always displayed at the top above all other layers (e.g. a highlight layer) */\n #topMostOperationalLayers = reactiveArray<LayerType>();\n\n /** All base layers */\n #baseLayers = reactiveArray<LayerType>();\n\n #syncHandle: Resource | undefined;\n\n /** @internal */\n constructor(map: MapModel, tag: InternalConstructorTag) {\n assertInternalConstructor(tag);\n\n this.#map = map;\n this.#syncHandle = effect(() => {\n // Contains base layers, normal operational layers, topmost layers in bottom-to-top order.\n const orderedLayers = this.getLayers({\n sortByDisplayOrder: true,\n includeInternalLayers: true\n });\n\n // Simply reassign all z-indices whenever the order changes.\n let index = 0;\n for (const layer of orderedLayers) {\n LOG.isDebug() && LOG.debug(\"Assigning z-index\", layer.id, index);\n layer.olLayer.setZIndex(index);\n index++;\n }\n });\n }\n\n destroy() {\n for (const layer of this.#layersById.values()) {\n layer.destroy();\n }\n this.#topLevelLayers.clear();\n this.#layersById.clear();\n this.#operationalLayerOrder.splice(0, this.#operationalLayerOrder.length);\n this.#activeBaseLayer.value = undefined;\n this.#syncHandle?.destroy();\n this.#syncHandle = undefined;\n }\n\n /**\n * Adds a new layer to the map.\n *\n * The new layer is automatically registered with this collection.\n *\n * ### Display order\n *\n * By default, the new layer will be shown on _top_ of all normal operational layers.\n * Use the `options` parameter to control the insertion point.\n *\n * ### Ownership\n *\n * The map model takes ownership of the new layer.\n * This means that the layer will be destroyed if the map model is destroyed.\n */\n addLayer(layer: Layer, options?: AddLayerOptions): void {\n batch(() => {\n checkLayerInstance(layer);\n checkIncorrectAddLayerOptions(layer, options);\n\n if (layer[DECLARED_AS_BASE_LAYER]) {\n options = options ? { ...options, at: \"base\" } : { at: \"base\" };\n }\n\n layer[ATTACH_TO_MAP](this.#map);\n this.#addLayer(layer, options);\n });\n }\n\n /**\n * Returns all configured base layers.\n */\n getBaseLayers(): Layer[] {\n return Array.from(this.#baseLayers);\n }\n\n /**\n * Returns the currently active base layer.\n */\n getActiveBaseLayer(): Layer | undefined {\n return this.#activeBaseLayer.value;\n }\n\n /**\n * Activates the base layer with the given id.\n * `undefined` can be used to hide all base layers.\n *\n * The associated layer is made visible and all other base layers are hidden.\n *\n * Returns true if the given layer has been successfully activated.\n */\n activateBaseLayer(id: string | undefined): boolean {\n let newBaseLayer = undefined;\n if (id != null) {\n newBaseLayer = this.#layersById.get(id);\n if (!newBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is unknown.`);\n return false;\n }\n if (!(newBaseLayer instanceof AbstractLayer)) {\n LOG.warn(`Cannot activate base layer '${id}: layer has an invalid type.'`);\n return false;\n }\n if (!newBaseLayer.isBaseLayer) {\n LOG.warn(`Cannot activate base layer '${id}': layer is not a base layer.`);\n return false;\n }\n }\n\n this.#updateBaseLayer(newBaseLayer);\n return true;\n }\n\n /**\n * Returns a list of operational layers, starting from the root of the map's layer hierarchy.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n */\n getOperationalLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options).filter((layer) => !this.#baseLayers.includes(layer));\n }\n\n /**\n * Returns a list of layers known to this collection. This includes base layers and operational layers.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n */\n getLayers(options?: LayerRetrievalOptions): Layer[] {\n let allLayers: Layer[];\n\n if (options?.sortByDisplayOrder) {\n const baseLayers = this.getBaseLayers();\n const order = Array.from(this.#operationalLayerOrder);\n const topMost = Array.from(this.#topMostOperationalLayers);\n allLayers = [...baseLayers, ...order, ...topMost];\n } else {\n allLayers = Array.from(this.#topLevelLayers.values());\n }\n\n if (!options?.includeInternalLayers) {\n allLayers = allLayers.filter((l) => !l.internal);\n }\n return allLayers;\n }\n\n /**\n * Returns a list of layers known to this collection. This includes base layers and operational layers.\n * The returned list includes top level layers only. Use {@link getRecursiveLayers()} to retrieve (nested) child layers.\n *\n * @deprecated Use {@link getLayers()}, {@link getOperationalLayers()} or {@link getRecursiveLayers()} instead.\n * This method name is misleading since it does not recurse into child layers.\n */\n getAllLayers(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n /**\n * Returns a list of all layers in this collection, including all children (recursively).\n *\n * > Note: This includes base layers by default (see `options.filter`).\n * > Use the `\"base\"` or `\"operational\"` short hand values to filter by base layer or operational layers.\n * >\n * > If the layer hierarchy is deeply nested, this function could potentially be expensive.\n */\n getRecursiveLayers({\n filter,\n sortByDisplayOrder,\n includeInternalLayers\n }: Omit<RecursiveRetrievalOptions, \"filter\"> & {\n filter?: \"base\" | \"operational\" | ((layer: AnyLayer) => boolean);\n } = {}): AnyLayer[] {\n let filterFunc;\n if (typeof filter === \"function\") {\n filterFunc = filter;\n } else if (typeof filter === \"string\") {\n const filterType = filter;\n const topLevelFilter = (layer: Layer) => {\n return filterType === \"base\" ? layer.isBaseLayer : !layer.isBaseLayer;\n };\n filterFunc = (layer: AnyLayer) => {\n if (!layer.parent && \"isBaseLayer\" in layer) {\n return topLevelFilter(layer);\n }\n // For nested children, include them all.\n return true;\n };\n }\n\n return getRecursiveLayers({\n from: this,\n filter: filterFunc,\n sortByDisplayOrder,\n includeInternalLayers\n });\n }\n\n getItems(options?: LayerRetrievalOptions): Layer[] {\n return this.getLayers(options);\n }\n\n /**\n * Returns the layer identified by the `id` or undefined, if no such layer exists.\n */\n getLayerById(id: string): AnyLayer | undefined {\n return this.#layersById.get(id);\n }\n\n /**\n * Removes a layer identified by the `id` from the map.\n *\n * NOTE: The current implementation only supports removal of _top level_ layers.\n *\n * ### Ownership\n *\n * This function _destroys_ the layer instance and all its children.\n *\n * @deprecated Use {@link removeLayer} instead.\n */\n removeLayerById(id: string): void {\n batch(() => {\n const layer = this.#layersById.get(id);\n if (!layer) {\n LOG.isDebug() && LOG.debug(`Cannot remove layer '${id}': layer is unknown.`);\n return;\n }\n\n checkLayerInstance(layer);\n if (!this.#topLevelLayers.has(layer)) {\n LOG.warn(\n `Cannot remove layer '${layer.id}': only top level layers can be removed at this time.`\n );\n return;\n }\n\n this.#removeLayer(layer);\n layer.destroy();\n });\n }\n\n /**\n * Removes the given top level layer from the map.\n *\n * The layer can be specified directly (as an object) or by an id.\n *\n * Returns the layer instance on success, or `undefined` if the layer was not found.\n *\n * ### Ownership\n *\n * The map releases ownership of this layer.\n * The caller can destroy it or store it for later reuse.\n */\n removeLayer(layer: string | Layer): Layer | undefined {\n return batch(() => {\n let actualLayer;\n if (typeof layer === \"string\") {\n actualLayer = this.#layersById.get(layer);\n if (!actualLayer) {\n return undefined;\n }\n } else {\n actualLayer = layer;\n }\n\n checkLayerInstance(actualLayer);\n if (!this.#topLevelLayers.has(actualLayer)) {\n return undefined;\n }\n\n this.#removeLayer(actualLayer);\n actualLayer[DETACH_FROM_MAP]();\n return actualLayer;\n });\n }\n\n /**\n * Given a raw OpenLayers layer instance, returns the associated {@link Layer} - or undefined\n * if the layer is unknown to this collection.\n */\n getLayerByRawInstance(layer: OlBaseLayer): Layer | undefined {\n return this.#layersByOlLayer?.get(layer);\n }\n\n /**\n * Adds the given layer to the map and all relevant indices.\n */\n #addLayer(layer: LayerType, options: AddLayerOptions | undefined) {\n // Throws; do this before manipulating the data structures\n const pos = this.#getInsertionPos(layer, options);\n this.#indexLayer(layer);\n\n // Everything below this line should not fail.\n if (pos.which === \"base\") {\n if (!this.#activeBaseLayer.value && layer.visible) {\n this.#updateBaseLayer(layer);\n } else {\n layer[SET_VISIBLE](false);\n }\n } else {\n layer[SET_VISIBLE](layer.visible);\n }\n\n const layerList = this.#getLayerList(pos);\n layerList.splice(pos.index, 0, layer); // insert new layer at insertion index\n this.#topLevelLayers.add(layer);\n this.#map.olMap.addLayer(layer.olLayer);\n }\n\n #getInsertionPos(layer: LayerType, options: AddLayerOptions | undefined): LayerPos {\n switch (options?.at) {\n case undefined:\n case null:\n case \"top\":\n return { which: \"normal\", index: this.#operationalLayerOrder.length };\n case \"topmost\":\n return { which: \"topmost\", index: this.#topMostOperationalLayers.length };\n case \"base\":\n return { which: \"base\", index: this.#baseLayers.length };\n case \"bottom\":\n return { which: \"normal\", index: 0 };\n case \"above\":\n case \"below\": {\n const reference = this.#getReference(options.reference);\n const pos = this.#findLayerPos(reference);\n if (!pos || pos.which === \"base\") {\n // reference is not a top level operational layer -> throw error\n const errorMessage = this.#getInsertErrorMessage(layer, reference);\n throw new Error(errorMessage);\n }\n\n if (options.at === \"above\") {\n pos.index++;\n }\n return pos;\n }\n }\n assertNever(options);\n }\n\n #getReference(reference: Layer | string): LayerType {\n let layer: AnyLayer;\n if (typeof reference === \"string\") {\n const refLayer = this.getLayerById(reference);\n if (!refLayer) {\n throw new Error(`Unknown reference layer '${reference}'.`);\n }\n layer = refLayer;\n } else {\n layer = reference;\n }\n checkLayerInstance(layer);\n return layer;\n }\n\n /**\n * Removes the given top level layer from the map and all relevant indices.\n */\n #removeLayer(layer: LayerType) {\n this.#map.olMap.removeLayer(layer.olLayer);\n this.#topLevelLayers.delete(layer);\n const pos = this.#findLayerPos(layer);\n if (!pos) {\n throw new Error(`Internal error: layer '${layer.id}' not found.`);\n }\n const layerList = this.#getLayerList(pos);\n layerList.splice(pos.index, 1);\n\n this.#unIndexLayer(layer);\n if (this.#activeBaseLayer.value === layer) {\n const newBaseLayer = this.getBaseLayers()[0];\n if (newBaseLayer) {\n checkLayerInstance(newBaseLayer);\n }\n this.#updateBaseLayer(newBaseLayer);\n }\n }\n\n #updateBaseLayer(layer: LayerType | undefined) {\n if (this.#activeBaseLayer.value === layer) {\n return;\n }\n\n if (LOG.isDebug()) {\n const getId = (layer: AbstractLayer | undefined) => {\n return layer ? `'${layer.id}'` : undefined;\n };\n\n LOG.debug(\n `Switching active base layer from ${getId(this.#activeBaseLayer.value)} to ${getId(layer)}`\n );\n }\n\n batch(() => {\n this.#activeBaseLayer.value?.[SET_VISIBLE](false);\n this.#activeBaseLayer.value = layer;\n layer?.[SET_VISIBLE](true);\n });\n }\n\n /**\n * Index the layer and all its children.\n */\n #indexLayer(layer: LayerType) {\n // layer id -> layer (or sublayer)\n const registrations: [string, OlBaseLayer | undefined][] = [];\n const visit = (layer: LayerType | (AbstractLayerBase & Sublayer)) => {\n const id = layer.id;\n const olLayer = \"olLayer\" in layer ? layer.olLayer : undefined;\n if (this.#layersById.has(id)) {\n throw new Error(\n `Layer id '${id}' is not unique. Either assign a unique id yourself ` +\n `or skip configuring 'id' for an automatically generated id.`\n );\n }\n if (olLayer && this.#layersByOlLayer.has(olLayer)) {\n throw new Error(`OlLayer used by layer '${id}' has already been used in map.`);\n }\n\n // Register this layer with the map.\n this.#layersById.set(id, layer);\n if (olLayer) {\n this.#layersByOlLayer.set(olLayer, layer as LayerType); // ol is present --> not a sublayer\n }\n registrations.push([id, olLayer]);\n\n // Recurse into nested children.\n for (const childLayer of layer.layers?.[GET_RAW_LAYERS]() ?? []) {\n visit(childLayer);\n }\n for (const sublayer of layer.sublayers?.[GET_RAW_SUBLAYERS]() ?? []) {\n visit(sublayer);\n }\n };\n\n try {\n visit(layer);\n } catch (e) {\n // If any error happens, undo the indexing.\n // This way we don't leave a partially indexed layer tree behind.\n for (const [id, olLayer] of registrations) {\n this.#layersById.delete(id);\n if (olLayer) {\n this.#layersByOlLayer.delete(olLayer);\n }\n }\n throw e;\n }\n }\n\n /**\n * Removes index entries for the given layer and all its children.\n */\n #unIndexLayer(layer: AbstractLayer) {\n const visit = (layer: AbstractLayer | AbstractLayerBase) => {\n if (\"olLayer\" in layer) {\n this.#layersByOlLayer.delete(layer.olLayer);\n }\n this.#layersById.delete(layer.id);\n\n for (const childLayer of layer.layers?.[GET_RAW_LAYERS]() ?? []) {\n visit(childLayer);\n }\n\n for (const sublayer of layer.sublayers?.[GET_RAW_SUBLAYERS]() ?? []) {\n visit(sublayer);\n }\n };\n visit(layer);\n }\n\n #getLayerList(pos: LayerPos): ReactiveArray<LayerType> {\n switch (pos.which) {\n case \"topmost\":\n return this.#topMostOperationalLayers;\n case \"normal\":\n return this.#operationalLayerOrder;\n case \"base\":\n return this.#baseLayers;\n }\n }\n\n #findLayerPos(layer: LayerType): LayerPos | undefined {\n let index = this.#operationalLayerOrder.indexOf(layer);\n if (index !== -1) {\n return { which: \"normal\", index };\n }\n\n index = this.#topMostOperationalLayers.indexOf(layer);\n if (index !== -1) {\n return { which: \"topmost\", index };\n }\n\n index = this.#baseLayers.indexOf(layer);\n if (index !== -1) {\n return { which: \"base\", index };\n }\n\n return undefined;\n }\n\n #getInsertErrorMessage(layer: LayerType, reference: LayerType) {\n let message: string = `Cannot add layer '${layer.id}'. Reference layer '${reference.id}' is not a top level operational layer.`;\n\n if (reference.isBaseLayer) {\n //is base layer\n message += \" Reference layer is a base layer.\";\n } else if (reference.parent) {\n //is child layer\n message += \" Reference layer is child layer of a group.\";\n }\n\n return message;\n }\n}\n\nfunction checkIncorrectAddLayerOptions(layer: Layer, options: AddLayerOptions | undefined) {\n if (layer[DECLARED_AS_BASE_LAYER]) {\n if (options?.at === \"topmost\") {\n throw new Error(`Cannot add base layer '${layer.id}' as a topmost layer.`);\n } else if (options?.at && options.at !== \"base\") {\n throw new Error(\n `Cannot add base layer '${layer.id}' at a specific position: only operational layers can be added at a specific position.`\n );\n }\n }\n}\n\nfunction checkLayerInstance(object: AnyLayer): asserts object is Layer & AbstractLayer {\n if (!(object instanceof AbstractLayer)) {\n throw new Error(\n `Layer is not a valid layer instance. Use one of the classes provided by the map package instead.`\n );\n }\n}\n\nfunction assertNever(_arg: never): never {\n throw new Error(`Internal error: unhandled option.`);\n}\n"],"names":["layer"],"mappings":";;;;;;;;AAmCA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAe1B,MAAM,eAAA,CAAgB;AAAA,EACzB,IAAA;AAAA;AAAA,EAGA,kBAAkB,WAAA,EAAuB;AAAA;AAAA,EAGzC,cAAc,WAAA,EAAmC;AAAA;AAAA,EAGjD,gBAAA,uBAAwD,OAAA,EAAQ;AAAA;AAAA,EAGhE,mBAAmB,QAAA,EAAoB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvC,yBAAyB,aAAA,EAAyB;AAAA;AAAA,EAGlD,4BAA4B,aAAA,EAAyB;AAAA;AAAA,EAGrD,cAAc,aAAA,EAAyB;AAAA,EAEvC,WAAA;AAAA;AAAA,EAGA,WAAA,CAAY,KAAe,GAAA,EAA6B;AACpD,IAAA,yBAAA,CAA0B,GAAG,CAAA;AAE7B,IAAA,IAAA,CAAK,IAAA,GAAO,GAAA;AACZ,IAAA,IAAA,CAAK,WAAA,GAAc,OAAO,MAAM;AAE5B,MAAA,MAAM,aAAA,GAAgB,KAAK,SAAA,CAAU;AAAA,QACjC,kBAAA,EAAoB,IAAA;AAAA,QACpB,qBAAA,EAAuB;AAAA,OAC1B,CAAA;AAGD,MAAA,IAAI,KAAA,GAAQ,CAAA;AACZ,MAAA,KAAA,MAAW,SAAS,aAAA,EAAe;AAC/B,QAAA,GAAA,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AAEzB,MAAA,OAAA,IAAW,6CAAA;AAAA,IACf;AAEA,IAAA,OAAO,OAAA;AAAA,EACX;AACJ;AAEA,SAAS,6BAAA,CAA8B,OAAc,OAAA,EAAsC;AACvF,EAAA,IAAI,KAAA,CAAM,sBAAsB,CAAA,EAAG;AAC/B,IAAA,IAAI,OAAA,EAAS,OAAO,SAAA,EAAW;AAC3B,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,uBAAA,EAA0B,KAAA,CAAM,EAAE,CAAA,qBAAA,CAAuB,CAAA;AAAA,IAC7E,CAAA,MAAA,IAAW,OAAA,EAAS,EAAA,IAAM,OAAA,CAAQ,OAAO,MAAA,EAAQ;AAC7C,MAAA,MAAM,IAAI,KAAA;AAAA,QACN,CAAA,uBAAA,EAA0B,MAAM,EAAE,CAAA,sFAAA;AAAA,OACtC;AAAA,IACJ;AAAA,EACJ;AACJ;AAEA,SAAS,mBAAmB,MAAA,EAA2D;AACnF,EAAA,IAAI,EAAE,kBAAkB,aAAA,CAAA,EAAgB;AACpC,IAAA,MAAM,IAAI,KAAA;AAAA,MACN,CAAA,gGAAA;AAAA,KACJ;AAAA,EACJ;AACJ;AAEA,SAAS,YAAY,IAAA,EAAoB;AACrC,EAAA,MAAM,IAAI,MAAM,CAAA,iCAAA,CAAmC,CAAA;AACvD;;;;"}
@@ -111,6 +111,22 @@ export interface MapConfig {
111
111
  * Note: base layers are always shown below all operational layers.
112
112
  */
113
113
  layers?: Layer[];
114
+ /**
115
+ * Configures the base layers of the map.
116
+ *
117
+ * Base layers are always displayed below all operational layers.
118
+ * Only one base layer can be active (visible) at a time.
119
+ *
120
+ * Note: Prefer this property over the `LayerConfig.isBaseLayer` property.
121
+ */
122
+ baseLayers?: Layer[];
123
+ /**
124
+ * Configures the topmost layers of the map.
125
+ *
126
+ * Topmost layers are always displayed above all operational layers and base layers.
127
+ * The order of topmost layers is determined by their order in this array, with layers defined later being displayed above earlier ones.
128
+ */
129
+ topmostLayers?: Layer[];
114
130
  /**
115
131
  * Whether to show the default attribution control.
116
132
  *
@@ -8,6 +8,7 @@ import { get } from 'ol/proj.js';
8
8
  import OSM from 'ol/source/OSM.js';
9
9
  import View from 'ol/View.js';
10
10
  import { sourceId$10 as sourceId } from '../_virtual/source-info.js';
11
+ import { DECLARED_AS_BASE_LAYER } from '../layers/shared/internals.js';
11
12
  import { INTERNAL_CONSTRUCTOR_TAG } from '../utils/InternalConstructorTag.js';
12
13
  import { patchOpenLayersClassesForTesting } from '../utils/ol-test-support.js';
13
14
  import { registerProjections } from '../utils/projections.js';
@@ -85,11 +86,43 @@ class MapModelFactory {
85
86
  );
86
87
  return batch(() => {
87
88
  try {
89
+ this.#assertUniqueLayerPlacement(mapConfig);
88
90
  if (mapConfig.layers) {
89
91
  for (const layerConfig of mapConfig.layers) {
92
+ if (mapConfig.baseLayers && layerConfig[DECLARED_AS_BASE_LAYER] != null) {
93
+ LOG.warn(
94
+ `Prefer to configure base layer '${layerConfig.title ?? layerConfig.id}' in the 'MapConfig.baseLayers' property instead of using the 'LayerConfig.isBaseLayer' property.`
95
+ );
96
+ }
90
97
  mapModel.layers.addLayer(layerConfig);
91
98
  }
92
99
  }
100
+ if (mapConfig.baseLayers) {
101
+ for (const layerConfig of mapConfig.baseLayers) {
102
+ if (layerConfig[DECLARED_AS_BASE_LAYER] != null) {
103
+ if (layerConfig[DECLARED_AS_BASE_LAYER]) {
104
+ LOG.warn(
105
+ `Base layer ${layerConfig.title ?? layerConfig.id} is already configured in the 'MapConfig.baseLayers' property. The 'LayerConfig.isBaseLayer' property can be omitted.`
106
+ );
107
+ } else {
108
+ LOG.warn(
109
+ `Base layer ${layerConfig.title ?? layerConfig.id} is configured in the 'MapConfig.baseLayers' property but 'LayerConfig.isBaseLayer' property is explicitly set to false. This layer will be treated as a base layer. Prefer using only the 'MapConfig.baseLayers' property for base layers.`
110
+ );
111
+ }
112
+ }
113
+ mapModel.layers.addLayer(layerConfig, { at: "base" });
114
+ }
115
+ }
116
+ if (mapConfig.topmostLayers) {
117
+ for (const layerConfig of mapConfig.topmostLayers) {
118
+ if (layerConfig[DECLARED_AS_BASE_LAYER] != null) {
119
+ LOG.warn(
120
+ `Topmost layer ${layerConfig.title ?? layerConfig.id} is configured in the 'MapConfig.topmostLayers'. The 'LayerConfig.isBaseLayer' property can be omitted.`
121
+ );
122
+ }
123
+ mapModel.layers.addLayer(layerConfig, { at: "topmost" });
124
+ }
125
+ }
93
126
  return mapModel;
94
127
  } catch (e) {
95
128
  mapModel.destroy();
@@ -163,6 +196,28 @@ Try to configure 'initialView' explicity.`
163
196
  }
164
197
  return projection;
165
198
  }
199
+ #assertUniqueLayerPlacement(mapConfig) {
200
+ const groups = /* @__PURE__ */ new Map([
201
+ ["baseLayers", mapConfig.baseLayers],
202
+ ["layers", mapConfig.layers],
203
+ ["topmostLayers", mapConfig.topmostLayers]
204
+ ]);
205
+ const groupByLayer = /* @__PURE__ */ new WeakMap();
206
+ for (const [groupName, layers] of groups) {
207
+ if (!layers) {
208
+ continue;
209
+ }
210
+ for (const layer of layers) {
211
+ const previousGroup = groupByLayer.get(layer);
212
+ if (previousGroup != null) {
213
+ throw new Error(
214
+ `Layer '${layer.title ?? layer.id}' is configured in both '${previousGroup}' and '${groupName}'. A layer may only appear in one layer list.`
215
+ );
216
+ }
217
+ groupByLayer.set(layer, groupName);
218
+ }
219
+ }
220
+ }
166
221
  }
167
222
 
168
223
  export { createMapModel };
@@ -1 +1 @@
1
- {"version":3,"file":"createMapModel.js","sources":["createMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { batch, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { MapBrowserEvent } from \"ol\";\nimport { getCenter } from \"ol/extent\";\nimport { DragZoom, defaults as defaultInteractions } from \"ol/interaction\";\nimport TileLayer from \"ol/layer/Tile\";\nimport OlMap, { MapOptions } from \"ol/Map\";\nimport { Projection, get as getProjection } from \"ol/proj\";\nimport OSM from \"ol/source/OSM\";\nimport View, { ViewOptions } from \"ol/View\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { INTERNAL_CONSTRUCTOR_TAG } from \"../utils/InternalConstructorTag\";\nimport { patchOpenLayersClassesForTesting } from \"../utils/ol-test-support\";\nimport { registerProjections } from \"../utils/projections\";\nimport { MapConfig } from \"./MapConfig\";\nimport { MapModel } from \"./MapModel\";\n\n/**\n * Register custom projection to the global proj4js definitions. User can select `EPSG:25832`\n * and `EPSG:25833` from the predefined projections without calling `registerProjections`.\n */\nregisterProjections({\n \"EPSG:25832\":\n \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n \"EPSG:25833\":\n \"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\"\n});\nconst LOG = createLogger(sourceId);\n\nexport async function createMapModel(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n): Promise<MapModel> {\n return await new MapModelFactory(mapId, mapConfig, currentIntl, httpService).createMapModel();\n}\n\nclass MapModelFactory {\n #mapId: string;\n #mapConfig: MapConfig;\n #currentIntl: ReadonlyReactive<PackageIntl>;\n #httpService: HttpService;\n\n constructor(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n ) {\n this.#mapId = mapId;\n this.#mapConfig = mapConfig;\n this.#currentIntl = currentIntl;\n this.#httpService = httpService;\n }\n\n async createMapModel() {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n const { view: viewOption, ...rawOlOptions } = mapConfig.advanced ?? {};\n const showDefaultAttributions =\n mapConfig.showAttributions ?? (rawOlOptions.controls ? false : true);\n\n const mapOptions: MapOptions = {\n ...rawOlOptions\n };\n if (!mapOptions.controls) {\n mapOptions.controls = [];\n }\n if (!mapOptions.interactions) {\n const shiftCtrlKeysOnly = (\n mapBrowserEvent: MapBrowserEvent<KeyboardEvent | WheelEvent | PointerEvent>\n ) => {\n const originalEvent = mapBrowserEvent.originalEvent;\n return (originalEvent.metaKey || originalEvent.ctrlKey) && originalEvent.shiftKey;\n };\n\n // setting altShiftDragRotate to false disables or excludes DragRotate interaction\n mapOptions.interactions = defaultInteractions({\n dragPan: true,\n altShiftDragRotate: false,\n pinchRotate: false,\n mouseWheelZoom: true\n }).extend([new DragZoom({ out: true, condition: shiftCtrlKeysOnly })]);\n }\n\n const view = (await viewOption) ?? {};\n this.#initializeViewOptions(view);\n mapOptions.view = view instanceof View ? view : new View(view);\n\n if (!mapOptions.layers && !mapConfig.layers) {\n mapOptions.layers = [\n new TileLayer({\n source: new OSM()\n })\n ];\n }\n\n const initialView = mapConfig.initialView;\n const initialExtent = initialView?.kind === \"extent\" ? initialView.extent : undefined;\n\n LOG.debug(`Constructing OpenLayers map with options`, mapOptions);\n\n if (import.meta.env.VITEST) {\n patchOpenLayersClassesForTesting();\n }\n\n const olMap = new OlMap(mapOptions);\n const mapModel = new MapModel(\n {\n id: mapId,\n olMap,\n initialExtent,\n showDefaultAttributions,\n currentIntl: this.#currentIntl,\n httpService: this.#httpService\n },\n INTERNAL_CONSTRUCTOR_TAG\n );\n\n return batch(() => {\n try {\n if (mapConfig.layers) {\n for (const layerConfig of mapConfig.layers) {\n mapModel.layers.addLayer(layerConfig);\n }\n }\n return mapModel;\n } catch (e) {\n mapModel.destroy();\n throw e;\n }\n });\n }\n\n #initializeViewOptions(view: View | ViewOptions) {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n if (view instanceof View) {\n const warn = (prop: string) => {\n LOG.warn(\n `The advanced configuration for map id '${mapId}' has provided a fully constructed view instance: ${prop} cannot be applied.\\n` +\n `Use ViewOptions instead of a View instance.`\n );\n };\n\n if (mapConfig.projection != null) {\n warn(\"projection\");\n }\n if (mapConfig.initialView != null) {\n warn(\"initialView\");\n }\n return;\n }\n\n const projection = (view.projection = this.#initializeProjection(mapConfig.projection));\n const initialView = mapConfig.initialView;\n if (initialView) {\n switch (initialView.kind) {\n case \"position\":\n view.zoom = initialView.zoom;\n view.center = [initialView.center.x, initialView.center.y];\n break;\n case \"extent\": {\n /*\n OpenLayers does not support configuration of the initial map extent.\n The only relevant options here are center, zoom (and resolution).\n We must set those values because otherwise OpenLayers will not initialize layer sources.\n\n The actual initial extent is applied once tha map has loaded and its size is known.\n */\n const extent = initialView.extent;\n view.zoom = 0;\n view.center = [\n extent.xMin + (extent.xMax - extent.xMin) / 2,\n extent.yMin + (extent.yMax - extent.yMin) / 2\n ];\n break;\n }\n }\n } else {\n this.#setViewDefaults(view, projection);\n }\n }\n\n #setViewDefaults(view: ViewOptions, projection: Projection) {\n if (view.center == null) {\n const extent = projection.getExtent(); // can be null\n if (!extent) {\n LOG.warn(\n `Cannot set default center coordinate because the current projection has no associated extent.\\n` +\n `Try to configure 'initialView' explicity.`\n );\n } else {\n view.center = getCenter(extent);\n }\n }\n\n if (view.zoom == null || view.resolution == null) {\n view.zoom = 0;\n }\n }\n\n #initializeProjection(projectionOption: MapConfig[\"projection\"]) {\n if (projectionOption == null) {\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n return getProjection(\"EPSG:3857\")!; // default OpenLayers projection\n }\n\n const projection = getProjection(projectionOption);\n if (!projection) {\n throw new Error(`Failed to retrieve projection for code '${projectionOption}'.`);\n }\n return projection;\n }\n}\n"],"names":["defaultInteractions","getProjection"],"mappings":";;;;;;;;;;;;;;;AA0BA,mBAAA,CAAoB;AAAA,EAChB,YAAA,EACI,oFAAA;AAAA,EACJ,YAAA,EACI;AACR,CAAC,CAAA;AACD,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,eAAsB,cAAA,CAClB,KAAA,EACA,SAAA,EACA,WAAA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B,CAAA;AACjD,IAAA,IAAI,CAAC,UAAA,EAAY;AACb,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,wCAAA,EAA2C,gBAAgB,CAAA,EAAA,CAAI,CAAA;AAAA,IACnF;AACA,IAAA,OAAO,UAAA;AAAA,EACX;AACJ;;;;"}
1
+ {"version":3,"file":"createMapModel.js","sources":["createMapModel.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { batch, ReadonlyReactive } from \"@conterra/reactivity-core\";\nimport { createLogger } from \"@open-pioneer/core\";\nimport { HttpService } from \"@open-pioneer/http\";\nimport { PackageIntl } from \"@open-pioneer/runtime\";\nimport { MapBrowserEvent } from \"ol\";\nimport { getCenter } from \"ol/extent\";\nimport { DragZoom, defaults as defaultInteractions } from \"ol/interaction\";\nimport TileLayer from \"ol/layer/Tile\";\nimport OlMap, { MapOptions } from \"ol/Map\";\nimport { Projection, get as getProjection } from \"ol/proj\";\nimport OSM from \"ol/source/OSM\";\nimport View, { ViewOptions } from \"ol/View\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { Layer } from \"..\";\nimport { DECLARED_AS_BASE_LAYER } from \"../layers/shared/internals\";\nimport { INTERNAL_CONSTRUCTOR_TAG } from \"../utils/InternalConstructorTag\";\nimport { patchOpenLayersClassesForTesting } from \"../utils/ol-test-support\";\nimport { registerProjections } from \"../utils/projections\";\nimport { MapConfig } from \"./MapConfig\";\nimport { MapModel } from \"./MapModel\";\n\n/**\n * Register custom projection to the global proj4js definitions. User can select `EPSG:25832`\n * and `EPSG:25833` from the predefined projections without calling `registerProjections`.\n */\nregisterProjections({\n \"EPSG:25832\":\n \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n \"EPSG:25833\":\n \"+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\"\n});\nconst LOG = createLogger(sourceId);\n\nexport async function createMapModel(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n): Promise<MapModel> {\n return await new MapModelFactory(mapId, mapConfig, currentIntl, httpService).createMapModel();\n}\n\nclass MapModelFactory {\n #mapId: string;\n #mapConfig: MapConfig;\n #currentIntl: ReadonlyReactive<PackageIntl>;\n #httpService: HttpService;\n\n constructor(\n mapId: string,\n mapConfig: MapConfig,\n currentIntl: ReadonlyReactive<PackageIntl>,\n httpService: HttpService\n ) {\n this.#mapId = mapId;\n this.#mapConfig = mapConfig;\n this.#currentIntl = currentIntl;\n this.#httpService = httpService;\n }\n\n async createMapModel() {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n const { view: viewOption, ...rawOlOptions } = mapConfig.advanced ?? {};\n const showDefaultAttributions =\n mapConfig.showAttributions ?? (rawOlOptions.controls ? false : true);\n\n const mapOptions: MapOptions = {\n ...rawOlOptions\n };\n if (!mapOptions.controls) {\n mapOptions.controls = [];\n }\n if (!mapOptions.interactions) {\n const shiftCtrlKeysOnly = (\n mapBrowserEvent: MapBrowserEvent<KeyboardEvent | WheelEvent | PointerEvent>\n ) => {\n const originalEvent = mapBrowserEvent.originalEvent;\n return (originalEvent.metaKey || originalEvent.ctrlKey) && originalEvent.shiftKey;\n };\n\n // setting altShiftDragRotate to false disables or excludes DragRotate interaction\n mapOptions.interactions = defaultInteractions({\n dragPan: true,\n altShiftDragRotate: false,\n pinchRotate: false,\n mouseWheelZoom: true\n }).extend([new DragZoom({ out: true, condition: shiftCtrlKeysOnly })]);\n }\n\n const view = (await viewOption) ?? {};\n this.#initializeViewOptions(view);\n mapOptions.view = view instanceof View ? view : new View(view);\n\n if (!mapOptions.layers && !mapConfig.layers) {\n mapOptions.layers = [\n new TileLayer({\n source: new OSM()\n })\n ];\n }\n\n const initialView = mapConfig.initialView;\n const initialExtent = initialView?.kind === \"extent\" ? initialView.extent : undefined;\n\n LOG.debug(`Constructing OpenLayers map with options`, mapOptions);\n\n if (import.meta.env.VITEST) {\n patchOpenLayersClassesForTesting();\n }\n\n const olMap = new OlMap(mapOptions);\n const mapModel = new MapModel(\n {\n id: mapId,\n olMap,\n initialExtent,\n showDefaultAttributions,\n currentIntl: this.#currentIntl,\n httpService: this.#httpService\n },\n INTERNAL_CONSTRUCTOR_TAG\n );\n\n return batch(() => {\n try {\n this.#assertUniqueLayerPlacement(mapConfig);\n if (mapConfig.layers) {\n for (const layerConfig of mapConfig.layers) {\n if (mapConfig.baseLayers && layerConfig[DECLARED_AS_BASE_LAYER] != null) {\n LOG.warn(\n `Prefer to configure base layer '${layerConfig.title ?? layerConfig.id}' in the 'MapConfig.baseLayers' property instead of using the 'LayerConfig.isBaseLayer' property.`\n );\n }\n\n mapModel.layers.addLayer(layerConfig);\n }\n }\n if (mapConfig.baseLayers) {\n for (const layerConfig of mapConfig.baseLayers) {\n if (layerConfig[DECLARED_AS_BASE_LAYER] != null) {\n if (layerConfig[DECLARED_AS_BASE_LAYER]) {\n LOG.warn(\n `Base layer ${layerConfig.title ?? layerConfig.id} is already configured in the 'MapConfig.baseLayers' property. The 'LayerConfig.isBaseLayer' property can be omitted.`\n );\n } else {\n LOG.warn(\n `Base layer ${layerConfig.title ?? layerConfig.id} is configured in the 'MapConfig.baseLayers' property but 'LayerConfig.isBaseLayer' property is explicitly set to false. This layer will be treated as a base layer. Prefer using only the 'MapConfig.baseLayers' property for base layers.`\n );\n }\n }\n\n mapModel.layers.addLayer(layerConfig, { at: \"base\" });\n }\n }\n if (mapConfig.topmostLayers) {\n for (const layerConfig of mapConfig.topmostLayers) {\n if (layerConfig[DECLARED_AS_BASE_LAYER] != null) {\n LOG.warn(\n `Topmost layer ${layerConfig.title ?? layerConfig.id} is configured in the 'MapConfig.topmostLayers'. The 'LayerConfig.isBaseLayer' property can be omitted.`\n );\n }\n\n mapModel.layers.addLayer(layerConfig, { at: \"topmost\" });\n }\n }\n return mapModel;\n } catch (e) {\n mapModel.destroy();\n throw e;\n }\n });\n }\n\n #initializeViewOptions(view: View | ViewOptions) {\n const mapId = this.#mapId;\n const mapConfig = this.#mapConfig;\n if (view instanceof View) {\n const warn = (prop: string) => {\n LOG.warn(\n `The advanced configuration for map id '${mapId}' has provided a fully constructed view instance: ${prop} cannot be applied.\\n` +\n `Use ViewOptions instead of a View instance.`\n );\n };\n\n if (mapConfig.projection != null) {\n warn(\"projection\");\n }\n if (mapConfig.initialView != null) {\n warn(\"initialView\");\n }\n return;\n }\n\n const projection = (view.projection = this.#initializeProjection(mapConfig.projection));\n const initialView = mapConfig.initialView;\n if (initialView) {\n switch (initialView.kind) {\n case \"position\":\n view.zoom = initialView.zoom;\n view.center = [initialView.center.x, initialView.center.y];\n break;\n case \"extent\": {\n /*\n OpenLayers does not support configuration of the initial map extent.\n The only relevant options here are center, zoom (and resolution).\n We must set those values because otherwise OpenLayers will not initialize layer sources.\n\n The actual initial extent is applied once tha map has loaded and its size is known.\n */\n const extent = initialView.extent;\n view.zoom = 0;\n view.center = [\n extent.xMin + (extent.xMax - extent.xMin) / 2,\n extent.yMin + (extent.yMax - extent.yMin) / 2\n ];\n break;\n }\n }\n } else {\n this.#setViewDefaults(view, projection);\n }\n }\n\n #setViewDefaults(view: ViewOptions, projection: Projection) {\n if (view.center == null) {\n const extent = projection.getExtent(); // can be null\n if (!extent) {\n LOG.warn(\n `Cannot set default center coordinate because the current projection has no associated extent.\\n` +\n `Try to configure 'initialView' explicity.`\n );\n } else {\n view.center = getCenter(extent);\n }\n }\n\n if (view.zoom == null || view.resolution == null) {\n view.zoom = 0;\n }\n }\n\n #initializeProjection(projectionOption: MapConfig[\"projection\"]) {\n if (projectionOption == null) {\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n return getProjection(\"EPSG:3857\")!; // default OpenLayers projection\n }\n\n const projection = getProjection(projectionOption);\n if (!projection) {\n throw new Error(`Failed to retrieve projection for code '${projectionOption}'.`);\n }\n return projection;\n }\n\n #assertUniqueLayerPlacement(mapConfig: MapConfig) {\n type GroupName = \"baseLayers\" | \"layers\" | \"topmostLayers\";\n\n const groups = new Map<GroupName, Layer[] | undefined>([\n [\"baseLayers\", mapConfig.baseLayers],\n [\"layers\", mapConfig.layers],\n [\"topmostLayers\", mapConfig.topmostLayers]\n ]);\n const groupByLayer = new WeakMap<Layer, GroupName>();\n\n for (const [groupName, layers] of groups) {\n if (!layers) {\n continue;\n }\n\n for (const layer of layers) {\n const previousGroup = groupByLayer.get(layer);\n if (previousGroup != null) {\n throw new Error(\n `Layer '${layer.title ?? layer.id}' is configured in both '${previousGroup}' and '${groupName}'. ` +\n `A layer may only appear in one layer list.`\n );\n }\n groupByLayer.set(layer, groupName);\n }\n }\n }\n}\n"],"names":["defaultInteractions","getProjection"],"mappings":";;;;;;;;;;;;;;;;AA4BA,mBAAA,CAAoB;AAAA,EAChB,YAAA,EACI,oFAAA;AAAA,EACJ,YAAA,EACI;AACR,CAAC,CAAA;AACD,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAEjC,eAAsB,cAAA,CAClB,KAAA,EACA,SAAA,EACA,WAAA,EACA,WAAA,EACiB;AACjB,EAAA,OAAO,MAAM,IAAI,eAAA,CAAgB,KAAA,EAAO,WAAW,WAAA,EAAa,WAAW,EAAE,cAAA,EAAe;AAChG;AAEA,MAAM,eAAA,CAAgB;AAAA,EAClB,MAAA;AAAA,EACA,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EAEA,WAAA,CACI,KAAA,EACA,SAAA,EACA,WAAA,EACA,WAAA,EACF;AACE,IAAA,IAAA,CAAK,MAAA,GAAS,KAAA;AACd,IAAA,IAAA,CAAK,UAAA,GAAa,SAAA;AAClB,IAAA,IAAA,CAAK,YAAA,GAAe,WAAA;AACpB,IAAA,IAAA,CAAK,YAAA,GAAe,WAAA;AAAA,EACxB;AAAA,EAEA,MAAM,cAAA,GAAiB;AACnB,IAAA,MAAM,QAAQ,IAAA,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BAAmB,OAAA,EAA0B;AAEnD,IAAA,KAAA,MAAW,CAAC,SAAA,EAAW,MAAM,CAAA,IAAK,MAAA,EAAQ;AACtC,MAAA,IAAI,CAAC,MAAA,EAAQ;AACT,QAAA;AAAA,MACJ;AAEA,MAAA,KAAA,MAAW,SAAS,MAAA,EAAQ;AACxB,QAAA,MAAM,aAAA,GAAgB,YAAA,CAAa,GAAA,CAAI,KAAK,CAAA;AAC5C,QAAA,IAAI,iBAAiB,IAAA,EAAM;AACvB,UAAA,MAAM,IAAI,KAAA;AAAA,YACN,CAAA,OAAA,EAAU,MAAM,KAAA,IAAS,KAAA,CAAM,EAAE,CAAA,yBAAA,EAA4B,aAAa,UAAU,SAAS,CAAA,6CAAA;AAAA,WAEjG;AAAA,QACJ;AACA,QAAA,YAAA,CAAa,GAAA,CAAI,OAAO,SAAS,CAAA;AAAA,MACrC;AAAA,IACJ;AAAA,EACJ;AACJ;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/map",
4
- "version": "1.4.0",
4
+ "version": "1.5.0-dev.20260910103330",
5
5
  "description": "This package integrates OpenLayers maps into an open pioneer trails application.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -14,21 +14,25 @@
14
14
  "directory": "src/packages/map"
15
15
  },
16
16
  "dependencies": {
17
- "@chakra-ui/react": "^3.36.1",
18
- "@conterra/reactivity-core": "^0.8.6",
19
- "@conterra/reactivity-events": "^0.8.6",
17
+ "@chakra-ui/react": "^3.37.0",
18
+ "@conterra/reactivity-core": "^0.8.8",
19
+ "@conterra/reactivity-events": "^0.8.8",
20
20
  "@esri/arcgis-html-sanitizer": "^4.1.0",
21
- "@open-pioneer/core": "^4.7.0",
22
- "@open-pioneer/http": "^4.7.0",
23
- "@open-pioneer/react-utils": "^4.7.0",
24
- "@open-pioneer/reactivity": "^4.7.0",
25
- "@open-pioneer/runtime": "^4.7.0",
26
- "ol": "^10.9.0",
27
- "proj4": "^2.20.9",
21
+ "@open-pioneer/core": "4.8.0-dev.20260910101405",
22
+ "@open-pioneer/http": "4.8.0-dev.20260910101405",
23
+ "@open-pioneer/react-utils": "4.8.0-dev.20260910101405",
24
+ "@open-pioneer/reactivity": "4.8.0-dev.20260910101405",
25
+ "@open-pioneer/runtime": "4.8.0-dev.20260910101405",
26
+ "ol": "^10.10.0",
27
+ "proj4": "^2.22.0",
28
28
  "react": "^19.2.8",
29
29
  "react-dom": "^19.2.8",
30
30
  "react-use": "^17.6.1",
31
- "uuid": "^14.0.1"
31
+ "uuid": "^14.0.2"
32
+ },
33
+ "publishConfig": {
34
+ "directory": "dist",
35
+ "linkDirectory": false
32
36
  },
33
37
  "exports": {
34
38
  "./package.json": "./package.json",
@@ -1 +1 @@
1
- {"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BoxProps, chakra, SystemStyleObject } from \"@chakra-ui/react\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport {\n CommonComponentProps,\n mergeChakraProps,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Extent } from \"ol/extent\";\nimport type OlMap from \"ol/Map\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReactNode, RefObject, useEffect, useMemo, useRef, useState } from \"react\";\nimport { DISPLAY_STATUS, MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { OverlaysRenderer } from \"./OverlaysRenderer\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n *\n * @default \"application\"\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n\n /**\n * Arbitrary html properties that will be applied to the map container's _root_ element.\n * This is the element that contains the map container and any UI elements (like map anchors, for example).\n *\n * Use these at your own risk since they may be overwritten by the map container root itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n rootProps?: BoxProps;\n\n /**\n * Arbitrary html properties that will be applied to the map container's element.\n * This is the element that _renders_ the OpenLayers map.\n *\n * Use these at your own risk since they may be overwritten by the map container itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n containerProps?: BoxProps;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n *\n * @group UI Components and Hooks\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior,\n children,\n role = \"application\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n rootProps,\n containerProps,\n ...restProps\n } = props;\n const { containerProps: rootContainerProps } = useCommonComponentProps(\n \"map-container-root\",\n restProps // hide role, aria label etc from helper\n );\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const map = useMapModelValue(props);\n const viewPadding = useViewPadding(viewPaddingProp);\n const [ready, setReady] = useState(false);\n\n // Register as renderer for map model\n useMapContainerRegistration(mapContainer, map);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const css = useRootCss(viewPadding);\n const mergedRootProps = useMemo(\n () => mergeChakraProps<BoxProps>({ css }, rootContainerProps, rootProps ?? {}),\n [css, rootProps, rootContainerProps]\n );\n const mergedContainerProps = useMemo(\n () =>\n mergeChakraProps<BoxProps>(\n {\n className: \"map-container\",\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n h: \"100%\",\n w: \"100%\",\n tabIndex: 0\n },\n containerProps ?? {}\n ),\n [role, ariaLabel, ariaLabelledBy, containerProps]\n );\n return (\n <chakra.div {...mergedRootProps}>\n {/* Used by open layers to mount the map. This node receives the keyboard focus when interacting with the map. */}\n <chakra.div ref={mapContainer} {...mergedContainerProps} />\n\n {/* Contains user widgets (map anchors and raw children). These are separate from the map so they don't interfere with mouse/keyboard events. */}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {ready && map && (\n <MapContainerReady\n map={map}\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: {\n map: MapModel;\n mapAnchorsHost: HTMLElement;\n viewPadding: Required<MapPadding>;\n } & Omit<MapContainerProps, \"mapId\" | \"map\" | \"className\">\n): ReactNode {\n const {\n map,\n mapAnchorsHost,\n viewPadding,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n // Apply view padding\n useSyncViewPadding(viewPadding, viewPaddingChangeBehavior, map);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return (\n <MapContainerContextProvider value={mapContext}>\n <OverlaysRenderer map={map} />\n {children}\n </MapContainerContextProvider>\n );\n}\n\n/**\n * Registers the map container as the map's renderer.\n * This can only be done once at a time: there cannot be two renderers for the same map model.\n */\nfunction useMapContainerRegistration(\n mapContainer: RefObject<HTMLDivElement | null>,\n map: MapModel\n) {\n useEffect(() => {\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [mapContainer, map]);\n}\n\n/**\n * Custom CSS rules for the root element.\n */\nfunction useRootCss(viewPadding: Required<MapPadding>) {\n return useMemo((): SystemStyleObject => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding.top}px`,\n \"--map-padding-bottom\": `${viewPadding.bottom}px`,\n \"--map-padding-left\": `${viewPadding.left}px`,\n \"--map-padding-right\": `${viewPadding.right}px`\n };\n }, [viewPadding]);\n}\n\n/**\n * Normalizes the view padding property.\n */\nfunction useViewPadding(viewPaddingProp: MapPadding | undefined): Required<MapPadding> {\n return useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [\n viewPaddingProp?.left,\n viewPaddingProp?.right,\n viewPaddingProp?.top,\n viewPaddingProp?.bottom\n ]);\n}\n\ninterface TargetViewPoint {\n center: Coordinate;\n extent: Extent | undefined;\n}\n\n/**\n * Applies the current view padding to the view.\n */\nfunction useSyncViewPadding(\n viewPadding: Required<MapPadding>,\n viewPaddingChangeBehavior: MapContainerProps[\"viewPaddingChangeBehavior\"],\n map: MapModel\n) {\n const mapView = useReactiveSnapshot(() => map.olView, [map]);\n\n // Tracks target state for in-progress animations.\n const targetViewPoint = useRef<TargetViewPoint>(undefined);\n\n useEffect(() => {\n const olMap = map.olMap;\n if (!mapView) {\n return;\n }\n\n const oldPadding = fromOlPadding(mapView.padding);\n const paddingNotChanged = isPaddingEqual(viewPadding, oldPadding);\n if (paddingNotChanged) {\n return;\n }\n\n let target = targetViewPoint.current;\n if (!target || !mapView.getAnimating()) {\n const currentCenter = mapView.getCenter();\n if (!currentCenter) {\n return;\n }\n targetViewPoint.current = target = {\n center: currentCenter,\n extent: extentIncludingPadding(olMap, oldPadding)\n };\n }\n mapView.padding = toOlPadding(viewPadding);\n\n const shouldAnimate = map[DISPLAY_STATUS] === \"ready\";\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\": {\n if (shouldAnimate) {\n mapView.animate({ center: target.center, duration: 300 }, (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n });\n } else {\n mapView.setCenter(target.center);\n targetViewPoint.current = undefined;\n }\n break;\n }\n case \"preserve-extent\": {\n if (target.extent) {\n const res = mapView.getResolutionForExtent(target.extent);\n if (shouldAnimate) {\n mapView.animate(\n {\n center: target.center,\n resolution: res,\n duration: 300\n },\n (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n }\n );\n } else {\n mapView.setCenter(target.center);\n mapView.setResolution(res);\n targetViewPoint.current = undefined;\n }\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, viewPaddingChangeBehavior, map, mapView]);\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n\nfunction isPaddingEqual(a: Required<MapPadding>, b: Required<MapPadding>): boolean {\n return a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAqBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAgF1B,SAAS,aAAa,KAAA,EAA0B;AACnD,EAAA,MAAM;AAAA,IACF,WAAA,EAAa,eAAA;AAAA,IACb,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,GAAO,aAAA;AAAA,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G;AAAA,GACnC,CAAA;AACD,EAAA,IAAI,CAAC,UAAA,IAAc,CAAC,QAAA,EAAU;AAC1B,IAAA,OAAO,MAAA;AAAA,EACX;AAEA,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,UAAA;AACrB,EAAA,MAAM,CAAC,IAAA,EAAM,IAAI,CAAA,GAAI,QAAA;AACrB,EAAA,OAAO,CAAC,IAAA,EAAM,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA;AAClC;AAEA,SAAS,cAAc,OAAA,EAAqD;AAExE,EAAA,OAAO;AAAA,IACH,GAAA,EAAK,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACrB,KAAA,EAAO,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACvB,MAAA,EAAQ,OAAA,GAAU,CAAC,CAAA,IAAK,CAAA;AAAA,IACxB,IAAA,EAAM,OAAA,GAAU,CAAC,CAAA,IAAK;AAAA,GAC1B;AACJ;AAEA,SAAS,YAAY,OAAA,EAAyC;AAE1D,EAAA,MAAM,EAAE,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,MAAK,GAAI,OAAA;AACrC,EAAA,OAAO,CAAC,GAAA,EAAK,KAAA,EAAO,MAAA,EAAQ,IAAI,CAAA;AACpC;AAEA,SAAS,cAAA,CAAe,GAAyB,CAAA,EAAkC;AAC/E,EAAA,OAAO,CAAA,CAAE,GAAA,KAAQ,CAAA,CAAE,GAAA,IAAO,EAAE,KAAA,KAAU,CAAA,CAAE,KAAA,IAAS,CAAA,CAAE,MAAA,KAAW,CAAA,CAAE,MAAA,IAAU,CAAA,CAAE,SAAS,CAAA,CAAE,IAAA;AAC3F;;;;"}
1
+ {"version":3,"file":"MapContainer.js","sources":["MapContainer.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BoxProps, chakra, SystemStyleObject } from \"@chakra-ui/react\";\nimport { createLogger, Resource } from \"@open-pioneer/core\";\nimport {\n CommonComponentProps,\n mergeChakraProps,\n useCommonComponentProps\n} from \"@open-pioneer/react-utils\";\nimport { useReactiveSnapshot } from \"@open-pioneer/reactivity\";\nimport { Coordinate } from \"ol/coordinate\";\nimport { Extent } from \"ol/extent\";\nimport type OlMap from \"ol/Map\";\nimport { sourceId } from \"open-pioneer:source-info\";\nimport { ReactNode, RefObject, useEffect, useMemo, useRef, useState } from \"react\";\nimport { DISPLAY_STATUS, MapModel, MapPadding } from \"../model/MapModel\";\nimport { MapModelProps, useMapModelValue } from \"./hooks/useMapModel\";\nimport { MapContainerContextProvider, MapContainerContextType } from \"./MapContainerContext\";\nimport { OverlaysRenderer } from \"./OverlaysRenderer\";\n\nconst LOG = createLogger(sourceId);\n\n/**\n * @group UI Components and Hooks\n */\nexport interface MapContainerProps extends CommonComponentProps, MapModelProps {\n /**\n * Sets the map's padding directly.\n * Do not use the view's padding property directly on the OL map.\n *\n * See: https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)\n */\n viewPadding?: MapPadding | undefined;\n\n /**\n * Behavior performed by the map when the view padding changes.\n *\n * - `none`: Do nothing.\n * - `preserve-center`: Ensures that the center point remains the same by animating the view.\n * - `preserve-extent`: Ensures that the extent remains the same by zooming.\n *\n * @default \"preserve-center\"\n */\n viewPaddingChangeBehavior?: \"none\" | \"preserve-center\" | \"preserve-extent\";\n\n children?: ReactNode;\n\n /**\n * Optional role property.\n *\n * This property is directly applied to the map's container div element.\n *\n * @default \"application\"\n */\n role?: string;\n\n /**\n * Optional aria-labelledby property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-labelledby\"?: string;\n\n /**\n * Optional aria-label property.\n * Do not use together with aria-label.\n *\n * This property is directly applied to the map's container div element.\n */\n \"aria-label\"?: string;\n\n /**\n * Arbitrary html properties that will be applied to the map container's _root_ element.\n * This is the element that contains the map container and any UI elements (like map anchors, for example).\n *\n * Use these at your own risk since they may be overwritten by the map container root itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n rootProps?: BoxProps;\n\n /**\n * Arbitrary html properties that will be applied to the map container's element.\n * This is the element that _renders_ the OpenLayers map.\n *\n * Use these at your own risk since they may be overwritten by the map container itself.\n *\n * Use cases: setting custom data attributes, registering custom event handlers, ...\n */\n containerProps?: BoxProps;\n}\n\n/**\n * Displays the map with the given id.\n *\n * There can only be at most one MapContainer for every map.\n *\n * @group UI Components and Hooks\n */\nexport function MapContainer(props: MapContainerProps) {\n const {\n viewPadding: viewPaddingProp,\n viewPaddingChangeBehavior,\n children,\n role = \"application\",\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n rootProps,\n containerProps,\n ...restProps\n } = props;\n const { containerProps: rootContainerProps } = useCommonComponentProps(\n \"map-container-root\",\n restProps // hide role, aria label etc from helper\n );\n const mapContainer = useRef<HTMLDivElement>(null);\n const mapAnchorsHost = useRef<HTMLDivElement>(null);\n const map = useMapModelValue(props);\n const viewPadding = useViewPadding(viewPaddingProp);\n const [ready, setReady] = useState(false);\n\n // Register as renderer for map model\n useMapContainerRegistration(mapContainer, map);\n\n // Wait for mount to make sure that the map anchors host is available\n useEffect(() => {\n setReady(true);\n }, []);\n\n const css = useRootCss(viewPadding);\n const mergedRootProps = useMemo(\n () => mergeChakraProps<BoxProps>({ css }, rootContainerProps, rootProps ?? {}),\n [css, rootProps, rootContainerProps]\n );\n const mergedContainerProps = useMemo(\n () =>\n mergeChakraProps<BoxProps>(\n {\n className: \"map-container\",\n role,\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledBy,\n h: \"100%\",\n w: \"100%\",\n tabIndex: 0\n },\n containerProps ?? {}\n ),\n [role, ariaLabel, ariaLabelledBy, containerProps]\n );\n return (\n <chakra.div {...mergedRootProps}>\n {/* Used by open layers to mount the map. This node receives the keyboard focus when interacting with the map. */}\n <chakra.div ref={mapContainer} {...mergedContainerProps} />\n\n {/* Contains user widgets (map anchors and raw children). These are separate from the map so they don't interfere with mouse/keyboard events. */}\n <chakra.div ref={mapAnchorsHost} className=\"map-anchors\">\n {ready && map && (\n <MapContainerReady\n map={map}\n // oxlint-disable-next-line @typescript-eslint/no-non-null-assertion react/refs\n mapAnchorsHost={mapAnchorsHost.current!}\n viewPadding={viewPadding}\n viewPaddingChangeBehavior={viewPaddingChangeBehavior}\n >\n {children}\n </MapContainerReady>\n )}\n </chakra.div>\n </chakra.div>\n );\n}\n\n/**\n * This inner component is rendered when the map has been loaded.\n *\n * It provides the map instance and additional properties down the component tree.\n */\nfunction MapContainerReady(\n props: {\n map: MapModel;\n mapAnchorsHost: HTMLElement;\n viewPadding: Required<MapPadding>;\n } & Omit<MapContainerProps, \"mapId\" | \"map\" | \"className\">\n): ReactNode {\n const {\n map,\n mapAnchorsHost,\n viewPadding,\n viewPaddingChangeBehavior = \"preserve-center\",\n children\n } = props;\n\n // Apply view padding\n useSyncViewPadding(viewPadding, viewPaddingChangeBehavior, map);\n\n const mapContext = useMemo((): MapContainerContextType => {\n return {\n mapAnchorsHost\n };\n }, [mapAnchorsHost]);\n return (\n <MapContainerContextProvider value={mapContext}>\n <OverlaysRenderer map={map} />\n {children}\n </MapContainerContextProvider>\n );\n}\n\n/**\n * Registers the map container as the map's renderer.\n * This can only be done once at a time: there cannot be two renderers for the same map model.\n */\nfunction useMapContainerRegistration(\n mapContainer: RefObject<HTMLDivElement | null>,\n map: MapModel\n) {\n useEffect(() => {\n // Mount the map into the DOM\n if (mapContainer.current) {\n const resource = registerMapTarget(map, mapContainer.current);\n return () => resource?.destroy();\n }\n }, [mapContainer, map]);\n}\n\n/**\n * Custom CSS rules for the root element.\n */\nfunction useRootCss(viewPadding: Required<MapPadding>) {\n return useMemo((): SystemStyleObject => {\n return {\n height: \"100%\",\n position: \"relative\",\n\n // set css variables according to view padding\n \"--map-padding-top\": `${viewPadding.top}px`,\n \"--map-padding-bottom\": `${viewPadding.bottom}px`,\n \"--map-padding-left\": `${viewPadding.left}px`,\n \"--map-padding-right\": `${viewPadding.right}px`\n };\n }, [viewPadding]);\n}\n\n/**\n * Normalizes the view padding property.\n */\nfunction useViewPadding(viewPaddingProp: MapPadding | undefined): Required<MapPadding> {\n return useMemo<Required<MapPadding>>(() => {\n return {\n left: viewPaddingProp?.left ?? 0,\n right: viewPaddingProp?.right ?? 0,\n top: viewPaddingProp?.top ?? 0,\n bottom: viewPaddingProp?.bottom ?? 0\n };\n }, [\n viewPaddingProp?.left,\n viewPaddingProp?.right,\n viewPaddingProp?.top,\n viewPaddingProp?.bottom\n ]);\n}\n\ninterface TargetViewPoint {\n center: Coordinate;\n extent: Extent | undefined;\n}\n\n/**\n * Applies the current view padding to the view.\n */\nfunction useSyncViewPadding(\n viewPadding: Required<MapPadding>,\n viewPaddingChangeBehavior: MapContainerProps[\"viewPaddingChangeBehavior\"],\n map: MapModel\n) {\n const mapView = useReactiveSnapshot(() => map.olView, [map]);\n\n // Tracks target state for in-progress animations.\n const targetViewPoint = useRef<TargetViewPoint>(undefined);\n\n useEffect(() => {\n const olMap = map.olMap;\n if (!mapView) {\n return;\n }\n\n const oldPadding = fromOlPadding(mapView.padding);\n const paddingNotChanged = isPaddingEqual(viewPadding, oldPadding);\n if (paddingNotChanged) {\n return;\n }\n\n let target = targetViewPoint.current;\n if (!target || !mapView.getAnimating()) {\n const currentCenter = mapView.getCenter();\n if (!currentCenter) {\n return;\n }\n targetViewPoint.current = target = {\n center: currentCenter,\n extent: extentIncludingPadding(olMap, oldPadding)\n };\n }\n mapView.padding = toOlPadding(viewPadding);\n\n const shouldAnimate = map[DISPLAY_STATUS] === \"ready\";\n switch (viewPaddingChangeBehavior) {\n case \"preserve-center\": {\n if (shouldAnimate) {\n mapView.animate({ center: target.center, duration: 300 }, (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n });\n } else {\n mapView.setCenter(target.center);\n targetViewPoint.current = undefined;\n }\n break;\n }\n case \"preserve-extent\": {\n if (target.extent) {\n const res = mapView.getResolutionForExtent(target.extent);\n if (shouldAnimate) {\n mapView.animate(\n {\n center: target.center,\n resolution: res,\n duration: 300\n },\n (done) => {\n if (done) {\n targetViewPoint.current = undefined;\n }\n }\n );\n } else {\n mapView.setCenter(target.center);\n mapView.setResolution(res);\n targetViewPoint.current = undefined;\n }\n }\n break;\n }\n case \"none\":\n }\n }, [viewPadding, viewPaddingChangeBehavior, map, mapView]);\n}\n\nfunction registerMapTarget(mapModel: MapModel, target: HTMLDivElement): Resource | undefined {\n const mapId = mapModel.id;\n const olMap = mapModel.olMap;\n if (olMap.getTarget()) {\n LOG.error(\n `Failed to display the map: the map already has a target. There may be more than one <MapContainer />.`\n );\n return undefined;\n }\n\n LOG.isDebug() && LOG.debug(`Setting target of map '${mapId}':`, target);\n if (!(\"keyboardEventTarget_\" in olMap)) {\n throw new Error(\n \"Internal error: failed to override keyboard event target. The property is no longer present.\"\n );\n }\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = target;\n olMap.setTarget(target);\n\n let unregistered = false;\n return {\n destroy() {\n if (!unregistered) {\n LOG.isDebug() && LOG.debug(`Removing target of map '${mapId}':`, target);\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n (olMap as any).keyboardEventTarget_ = undefined;\n olMap.setTarget(undefined);\n unregistered = true;\n }\n }\n };\n}\n\n/**\n * Returns the extent visible in the non-padded region of the map.\n */\nfunction extentIncludingPadding(map: OlMap, padding: Required<MapPadding>): Extent | undefined {\n const size = map.getSize();\n if (!size || size.length < 2) {\n return undefined;\n }\n\n const [width, height] = size as [number, number];\n const bottomLeft = map.getCoordinateFromPixel([padding.left, padding.bottom]);\n const topRight = map.getCoordinateFromPixel([\n Math.max(0, width - padding.right),\n Math.max(0, height - padding.top)\n ]);\n if (!bottomLeft || !topRight) {\n return undefined;\n }\n\n const [xmin, ymin] = bottomLeft;\n const [xmax, ymax] = topRight;\n return [xmin, ymin, xmax, ymax] as Extent;\n}\n\nfunction fromOlPadding(padding: number[] | undefined): Required<MapPadding> {\n // top, right, bottom, left\n return {\n top: padding?.[0] ?? 0,\n right: padding?.[1] ?? 0,\n bottom: padding?.[2] ?? 0,\n left: padding?.[3] ?? 0\n };\n}\n\nfunction toOlPadding(padding: Required<MapPadding>): number[] {\n // top, right, bottom, left\n const { top, right, bottom, left } = padding;\n return [top, right, bottom, left];\n}\n\nfunction isPaddingEqual(a: Required<MapPadding>, b: Required<MapPadding>): boolean {\n return a.top === b.top && a.right === b.right && a.bottom === b.bottom && a.left === b.left;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAqBA,MAAM,GAAA,GAAM,aAAa,QAAQ,CAAA;AAgF1B,SAAS,aAAa,KAAA,EAA0B;AACnD,EAAA,MAAM;AAAA,IACF,WAAA,EAAa,eAAA;AAAA,IACb,yBAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA,GAAO,aAAA;AAAA,IACP,YAAA,EAAc,SAAA;AAAA,IACd,iBAAA,EAAmB,cAAA;AAAA,IACnB,SAAA;AAAA,IACA,cAAA;AAAA,IACA,GAAG;AAAA,GACP,GAAI,KAAA;AACJ,EAAA,MAAM,EAAE,cAAA,EAAgB,kBAAA,EAAmB,GAAI,uBAAA;AAAA,IAC3C,oBAAA;AAAA,IACA;AAAA;AAAA,GACJ;AACA,EAAA,MAAM,YAAA,GAAe,OAAuB,IAAI,CAAA;AAChD,EAAA,MAAM,cAAA,GAAiB,OAAuB,IAAI,CAAA;AAClD,EAAA,MAAM,GAAA,GAAM,iBAAiB,KAAK,CAAA;AAClC,EAAA,MAAM,WAAA,GAAc,eAAe,eAAe,CAAA;AAClD,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,SAAS,KAAK,CAAA;AAGxC,EAAA,2BAAA,CAA4B,cAAc,GAAG,CAAA;AAG7C,EAAA,SAAA,CAAU,MAAM;AACZ,IAAA,QAAA,CAAS,IAAI,CAAA;AAAA,EACjB,CAAA,EAAG,EAAE,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