@open-pioneer/map 0.11.0 → 0.12.0-dev.20250725080856
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.
- package/CHANGELOG.md +24 -5
- package/api/layers/base.d.ts +17 -0
- package/api/layers/base.js.map +1 -1
- package/model/AbstractLayerBase.d.ts +3 -0
- package/model/AbstractLayerBase.js +8 -0
- package/model/AbstractLayerBase.js.map +1 -1
- package/package.json +4 -5
- package/projections.d.ts +3 -1
- package/projections.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
# @open-pioneer/map
|
|
2
2
|
|
|
3
|
+
## 0.12.0-dev.20250725080856
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 2702df4: Introduce `internal` property for all layer types (including sublayers). If `internal` is `true` (default: `false`) the layer is not considered by any UI widget (e.g. legend and Toc). The `internal` state of a layer is not to be confused with the layer's visibility on the map which is determined by the `visible` property.
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
//internal layer is visible on the map but hidden in UI elements like legend and Toc
|
|
11
|
+
const internalLayer = new SimpleLayer({
|
|
12
|
+
id: "layer1",
|
|
13
|
+
title: "layer 1",
|
|
14
|
+
olLayer: myOlLayer,
|
|
15
|
+
visible: true,
|
|
16
|
+
internal: true
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- 10d2fe7: Update dependencies
|
|
23
|
+
- 8986b3b: Remove obsolete dependency @types/proj4
|
|
24
|
+
- f1f69f2: Update to OpenLayers 10.6.1
|
|
25
|
+
- da6a410: Update dependencies
|
|
26
|
+
|
|
3
27
|
## 0.11.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
|
6
30
|
|
|
7
31
|
- 66179bc: Update to core-packages v4.0.0
|
|
8
32
|
- acd5115: **Breaking:** Remove the following hooks, which were deprecated since version 0.8.0:
|
|
9
|
-
|
|
10
33
|
- useView
|
|
11
34
|
- useProjection
|
|
12
35
|
- useResolution
|
|
@@ -259,7 +282,6 @@
|
|
|
259
282
|
`layer.children` is either an alias of `layer.sublayers` (if the layer has sublayers), `layer.layers` (if it's a `GroupLayer`) or undefined, if the layer does not have any children.
|
|
260
283
|
|
|
261
284
|
- d8337a6: The following hooks are deprecated and will be removed in a future release:
|
|
262
|
-
|
|
263
285
|
- `useView`
|
|
264
286
|
- `useProjection`
|
|
265
287
|
- `useResolution`
|
|
@@ -277,7 +299,6 @@
|
|
|
277
299
|
```
|
|
278
300
|
|
|
279
301
|
- 2fa8020: Update trails core package dependencies.
|
|
280
|
-
|
|
281
302
|
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
282
303
|
- Removes any obsolete references to `@chakra-ui/system`.
|
|
283
304
|
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
@@ -327,7 +348,6 @@
|
|
|
327
348
|
Sublayers (e.g. `WMSSublayer`) cannot be added to a group directly.
|
|
328
349
|
|
|
329
350
|
- d8337a6: Provide new reactive properties on the `MapModel` type.
|
|
330
|
-
|
|
331
351
|
- `olView` (-> `olMap.getView()`)
|
|
332
352
|
- `projection` (-> `olMap.getView().getProjection()`)
|
|
333
353
|
- `resolution` (-> `olMap.getView().getResolution()`)
|
|
@@ -359,7 +379,6 @@
|
|
|
359
379
|
Two type guards have been implemented that allow to check if a layer instance is a `Layer` or `Sublayer`: `isLayer()`and `isSublayer()` (see example below).
|
|
360
380
|
|
|
361
381
|
The following `type` attribute values have been implemented at the layers:
|
|
362
|
-
|
|
363
382
|
- SimpleLayer: `simple`
|
|
364
383
|
- WMSLayer: `wms`
|
|
365
384
|
- WMSSubLayer: `wms-sublayer`
|
package/api/layers/base.d.ts
CHANGED
|
@@ -42,6 +42,11 @@ export interface LayerBaseConfig {
|
|
|
42
42
|
* These can be arbitrary values.
|
|
43
43
|
*/
|
|
44
44
|
attributes?: Record<string | symbol, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Layers marked as internal are not considered by any UI widget (e.g. Toc or Legend)
|
|
47
|
+
* Defaults to `false`
|
|
48
|
+
*/
|
|
49
|
+
internal?: boolean;
|
|
45
50
|
}
|
|
46
51
|
/**
|
|
47
52
|
* Interface shared by all layer types (operational layers and sublayers).
|
|
@@ -110,6 +115,13 @@ export interface AnyLayerBaseType<AdditionalEvents = {}> extends EventSource<Lay
|
|
|
110
115
|
* The properties `layers` and `sublayers` are mutually exclusive.
|
|
111
116
|
*/
|
|
112
117
|
readonly sublayers: SublayersCollection | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Property that specifies if the layer is an "internal" layer. Internal layers are not considered by any UI widget (e.g. Toc or Legend).
|
|
120
|
+
* The internal state is independent of the layer's visibility which is determined by {@link visible}
|
|
121
|
+
*
|
|
122
|
+
* NOTE: Some UI widgets might use component specific attributes or props that have precedence over the internal property.
|
|
123
|
+
*/
|
|
124
|
+
readonly internal: boolean;
|
|
113
125
|
/**
|
|
114
126
|
* Additional attributes associated with this layer.
|
|
115
127
|
*/
|
|
@@ -129,6 +141,11 @@ export interface AnyLayerBaseType<AdditionalEvents = {}> extends EventSource<Lay
|
|
|
129
141
|
* Call {@link LayerCollection.activateBaseLayer} instead.
|
|
130
142
|
*/
|
|
131
143
|
setVisible(newVisibility: boolean): void;
|
|
144
|
+
/**
|
|
145
|
+
* Updates the internal property of this layer to the new value.
|
|
146
|
+
* @param newIsInternal
|
|
147
|
+
*/
|
|
148
|
+
setInternal(newIsInternal: boolean): void;
|
|
132
149
|
/**
|
|
133
150
|
* Updates the attributes of this layer.
|
|
134
151
|
* Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).
|
package/api/layers/base.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sources":["base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { EventSource } from \"@open-pioneer/core\";\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport type { MapModel } from \"../MapModel\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { GroupLayer, GroupLayerCollection } from \"./GroupLayer\";\nimport type { SimpleLayer } from \"./SimpleLayer\";\nimport type { WMSLayer, WMSSublayer } from \"./WMSLayer\";\nimport type { WMTSLayer } from \"./WMTSLayer\";\n\n/** Events emitted by the {@link Layer} and other layer types. */\nexport interface LayerBaseEvents {\n \"destroy\": void;\n}\n\n/** The load state of a layer. */\nexport type LayerLoadState = \"not-loaded\" | \"loading\" | \"loaded\" | \"error\";\n\n/** Custom function to check the state of a layer and returning a \"loaded\" or \"error\". */\nexport type HealthCheckFunction = (layer: Layer) => Promise<\"loaded\" | \"error\">;\n\n/**\n * Configuration options supported by all layer types (layers and sublayers).\n */\nexport interface LayerBaseConfig {\n /**\n * The unique id of this layer.\n * Defaults to a generated id.\n */\n id?: string;\n\n /**\n * The human-readable title of this layer.\n */\n title: string;\n\n /**\n * The human-readable description of this layer.\n * Defaults to an empty string.\n */\n description?: string;\n\n /**\n * Whether this layer should initially be visible.\n * Defaults to `true`.\n */\n visible?: boolean;\n\n /**\n * Additional attributes for this layer.\n * These can be arbitrary values.\n */\n attributes?: Record<string | symbol, unknown>;\n}\n\n/**\n * Interface shared by all layer types (operational layers and sublayers).\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface AnyLayerBaseType<AdditionalEvents = {}>\n extends EventSource<LayerBaseEvents & AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: AnyLayerTypes;\n\n /** The map this layer belongs to. */\n readonly map: MapModel;\n\n /**\n * The direct parent of this layer instance, used for sublayers or for layers in a group layer.\n *\n * The property shall be undefined if the layer is not a sublayer or member of a group layer.\n */\n readonly parent: AnyLayer | undefined;\n\n /**\n * The unique id of this layer within its map model.\n *\n * NOTE: layer ids may not be globally unique: layers that belong\n * to different map models may have the same id.\n */\n readonly id: string;\n\n /** The human-readable title of this layer. */\n readonly title: string;\n\n /** The human-readable description of this layer. May be empty. */\n readonly description: string;\n\n /**\n * Whether the layer is visible or not.\n *\n * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.\n * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.\n */\n readonly visible: boolean;\n\n /**\n * Legend URL from the service capabilities, if available.\n *\n * Note: this property may be expanded upon in the future, e.g. to support more variants than just image URLs.\n */\n readonly legend: string | undefined;\n\n /**\n * The direct children of this layer.\n *\n * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`.\n *\n * See also {@link layers} and {@link sublayers}.\n */\n readonly children: ChildrenCollection<AnyLayer> | undefined;\n\n /**\n * If this layer is a group layer this property contains a collection of all layers that a members to the group.\n *\n * The property shall be `undefined` if it is not a group layer.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly layers: GroupLayerCollection | undefined;\n\n /**\n * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer.\n *\n * Layers that can never have any sublayers may not have a `sublayers` collection.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly sublayers: SublayersCollection | undefined;\n\n /**\n * Additional attributes associated with this layer.\n */\n readonly attributes: Readonly<Record<string | symbol, unknown>>;\n\n /**\n * Updates the title of this layer.\n */\n setTitle(newTitle: string): void;\n\n /**\n * Updates the description of this layer.\n */\n setDescription(newDescription: string): void;\n\n /**\n * Updates the visibility of this layer to the new value.\n *\n * NOTE: The visibility of base layers cannot be changed through this method.\n * Call {@link LayerCollection.activateBaseLayer} instead.\n */\n setVisible(newVisibility: boolean): void;\n\n /**\n * Updates the attributes of this layer.\n * Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).\n */\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void;\n\n /**\n * Deletes the attribute of this layer.\n */\n deleteAttribute(deleteAttribute: string | symbol): void;\n}\n\n/**\n * Configuration options supported by all operational layer types.\n */\nexport interface LayerConfig extends LayerBaseConfig {\n /**\n * Whether this layer is a base layer or not.\n * Only one base layer can be active at a time.\n *\n * Defaults to `false`.\n */\n isBaseLayer?: boolean;\n\n /**\n * Optional property to check the availability of the layer.\n * It is possible to provide either a URL which indicates the state of the service (2xx response meaning \"ok\")\n * or a {@link HealthCheckFunction} performing a custom check and returning the state.\n */\n healthCheck?: string | HealthCheckFunction;\n}\n\n/**\n * Represents an operational layer in the map.\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: LayerTypes;\n\n /**\n * The load state of a layer.\n */\n readonly loadState: LayerLoadState;\n\n /**\n * The raw OpenLayers layer.\n */\n readonly olLayer: OlBaseLayer;\n\n /**\n * True if this layer is a base layer.\n *\n * Only one base layer can be visible at a time.\n */\n readonly isBaseLayer: boolean;\n}\n\n/**\n * Represents a sublayer of another layer.\n */\nexport interface SublayerBaseType extends AnyLayerBaseType {\n /**\n * Identifies the type of this sublayer.\n */\n readonly type: SublayerTypes;\n\n /**\n * The direct parent of this layer instance.\n * This can either be the parent layer or another sublayer.\n */\n readonly parent: AnyLayer;\n\n /**\n * The parent layer that owns this sublayer.\n */\n readonly parentLayer: Layer;\n}\n\n/**\n * Contains the children of a layer.\n */\nexport interface ChildrenCollection<LayerType> {\n /**\n * Returns the items in this collection.\n */\n getItems(options?: LayerRetrievalOptions): LayerType[];\n}\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n */\nexport interface SublayersCollection<SublayerType = Sublayer>\n extends ChildrenCollection<SublayerType> {\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions): SublayerType[];\n\n /**\n * Returns a list of all layers in the 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 collection contains many, deeply nested sublayers, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): Sublayer[];\n}\n\n/**\n * Union type for all layers (extending {@link LayerBaseType})\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\nexport type LayerTypes = Layer[\"type\"];\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}\n */\nexport type Sublayer = WMSSublayer;\nexport type SublayerTypes = Sublayer[\"type\"];\n\n/**\n * Union for all types of layers\n */\nexport type AnyLayer = Layer | Sublayer;\nexport type AnyLayerTypes = AnyLayer[\"type\"];\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\n */\nexport function isSublayer(layer: AnyLayer): layer is Sublayer {\n return \"parentLayer\" in layer;\n}\n\n/**\n * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).\n */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"AAqSO,SAAS,WAAW,KAAoC,EAAA;AAC3D,EAAA,OAAO,aAAiB,IAAA,KAAA;AAC5B;AAKO,SAAS,QAAQ,KAAiC,EAAA;AACrD,EAAA,OAAO,SAAa,IAAA,KAAA;AACxB;;;;"}
|
|
1
|
+
{"version":3,"file":"base.js","sources":["base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { EventSource } from \"@open-pioneer/core\";\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport type { MapModel } from \"../MapModel\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { GroupLayer, GroupLayerCollection } from \"./GroupLayer\";\nimport type { SimpleLayer } from \"./SimpleLayer\";\nimport type { WMSLayer, WMSSublayer } from \"./WMSLayer\";\nimport type { WMTSLayer } from \"./WMTSLayer\";\n\n/** Events emitted by the {@link Layer} and other layer types. */\nexport interface LayerBaseEvents {\n \"destroy\": void;\n}\n\n/** The load state of a layer. */\nexport type LayerLoadState = \"not-loaded\" | \"loading\" | \"loaded\" | \"error\";\n\n/** Custom function to check the state of a layer and returning a \"loaded\" or \"error\". */\nexport type HealthCheckFunction = (layer: Layer) => Promise<\"loaded\" | \"error\">;\n\n/**\n * Configuration options supported by all layer types (layers and sublayers).\n */\nexport interface LayerBaseConfig {\n /**\n * The unique id of this layer.\n * Defaults to a generated id.\n */\n id?: string;\n\n /**\n * The human-readable title of this layer.\n */\n title: string;\n\n /**\n * The human-readable description of this layer.\n * Defaults to an empty string.\n */\n description?: string;\n\n /**\n * Whether this layer should initially be visible.\n * Defaults to `true`.\n */\n visible?: boolean;\n\n /**\n * Additional attributes for this layer.\n * These can be arbitrary values.\n */\n attributes?: Record<string | symbol, unknown>;\n\n /**\n * Layers marked as internal are not considered by any UI widget (e.g. Toc or Legend)\n * Defaults to `false`\n */\n internal?: boolean;\n}\n\n/**\n * Interface shared by all layer types (operational layers and sublayers).\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface AnyLayerBaseType<AdditionalEvents = {}>\n extends EventSource<LayerBaseEvents & AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: AnyLayerTypes;\n\n /** The map this layer belongs to. */\n readonly map: MapModel;\n\n /**\n * The direct parent of this layer instance, used for sublayers or for layers in a group layer.\n *\n * The property shall be undefined if the layer is not a sublayer or member of a group layer.\n */\n readonly parent: AnyLayer | undefined;\n\n /**\n * The unique id of this layer within its map model.\n *\n * NOTE: layer ids may not be globally unique: layers that belong\n * to different map models may have the same id.\n */\n readonly id: string;\n\n /** The human-readable title of this layer. */\n readonly title: string;\n\n /** The human-readable description of this layer. May be empty. */\n readonly description: string;\n\n /**\n * Whether the layer is visible or not.\n *\n * NOTE: The model's visible state may do more than influence the raw OpenLayers's visibility property.\n * Future versions may completely remove invisible layers from the OpenLayer's map under some circumstances.\n */\n readonly visible: boolean;\n\n /**\n * Legend URL from the service capabilities, if available.\n *\n * Note: this property may be expanded upon in the future, e.g. to support more variants than just image URLs.\n */\n readonly legend: string | undefined;\n\n /**\n * The direct children of this layer.\n *\n * The children may either be a set of operational layers (e.g. for a group layer) or a set of sublayers, or `undefined`.\n *\n * See also {@link layers} and {@link sublayers}.\n */\n readonly children: ChildrenCollection<AnyLayer> | undefined;\n\n /**\n * If this layer is a group layer this property contains a collection of all layers that a members to the group.\n *\n * The property shall be `undefined` if it is not a group layer.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly layers: GroupLayerCollection | undefined;\n\n /**\n * The collection of child sublayers for this layer. Sublayers are layers that cannot exist without an appropriate parent layer.\n *\n * Layers that can never have any sublayers may not have a `sublayers` collection.\n *\n * The properties `layers` and `sublayers` are mutually exclusive.\n */\n readonly sublayers: SublayersCollection | undefined;\n\n /**\n * Property that specifies if the layer is an \"internal\" layer. Internal layers are not considered by any UI widget (e.g. Toc or Legend).\n * The internal state is independent of the layer's visibility which is determined by {@link visible}\n *\n * NOTE: Some UI widgets might use component specific attributes or props that have precedence over the internal property.\n */\n readonly internal: boolean;\n\n /**\n * Additional attributes associated with this layer.\n */\n readonly attributes: Readonly<Record<string | symbol, unknown>>;\n\n /**\n * Updates the title of this layer.\n */\n setTitle(newTitle: string): void;\n\n /**\n * Updates the description of this layer.\n */\n setDescription(newDescription: string): void;\n\n /**\n * Updates the visibility of this layer to the new value.\n *\n * NOTE: The visibility of base layers cannot be changed through this method.\n * Call {@link LayerCollection.activateBaseLayer} instead.\n */\n setVisible(newVisibility: boolean): void;\n\n /**\n * Updates the internal property of this layer to the new value.\n * @param newIsInternal\n */\n setInternal(newIsInternal: boolean): void;\n\n /**\n * Updates the attributes of this layer.\n * Values in `newAttributes` are merged into the existing ones (i.e. via `Object.assign`).\n */\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void;\n\n /**\n * Deletes the attribute of this layer.\n */\n deleteAttribute(deleteAttribute: string | symbol): void;\n}\n\n/**\n * Configuration options supported by all operational layer types.\n */\nexport interface LayerConfig extends LayerBaseConfig {\n /**\n * Whether this layer is a base layer or not.\n * Only one base layer can be active at a time.\n *\n * Defaults to `false`.\n */\n isBaseLayer?: boolean;\n\n /**\n * Optional property to check the availability of the layer.\n * It is possible to provide either a URL which indicates the state of the service (2xx response meaning \"ok\")\n * or a {@link HealthCheckFunction} performing a custom check and returning the state.\n */\n healthCheck?: string | HealthCheckFunction;\n}\n\n/**\n * Represents an operational layer in the map.\n *\n * Instances of this interface cannot be constructed directly; use a real layer\n * class such as {@link SimpleLayer} instead.\n */\nexport interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {\n /**\n * Identifies the type of this layer.\n */\n readonly type: LayerTypes;\n\n /**\n * The load state of a layer.\n */\n readonly loadState: LayerLoadState;\n\n /**\n * The raw OpenLayers layer.\n */\n readonly olLayer: OlBaseLayer;\n\n /**\n * True if this layer is a base layer.\n *\n * Only one base layer can be visible at a time.\n */\n readonly isBaseLayer: boolean;\n}\n\n/**\n * Represents a sublayer of another layer.\n */\nexport interface SublayerBaseType extends AnyLayerBaseType {\n /**\n * Identifies the type of this sublayer.\n */\n readonly type: SublayerTypes;\n\n /**\n * The direct parent of this layer instance.\n * This can either be the parent layer or another sublayer.\n */\n readonly parent: AnyLayer;\n\n /**\n * The parent layer that owns this sublayer.\n */\n readonly parentLayer: Layer;\n}\n\n/**\n * Contains the children of a layer.\n */\nexport interface ChildrenCollection<LayerType> {\n /**\n * Returns the items in this collection.\n */\n getItems(options?: LayerRetrievalOptions): LayerType[];\n}\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n */\nexport interface SublayersCollection<SublayerType = Sublayer>\n extends ChildrenCollection<SublayerType> {\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions): SublayerType[];\n\n /**\n * Returns a list of all layers in the 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 collection contains many, deeply nested sublayers, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): Sublayer[];\n}\n\n/**\n * Union type for all layers (extending {@link LayerBaseType})\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer | GroupLayer;\nexport type LayerTypes = Layer[\"type\"];\n\n/**\n * Union type for all sublayers (extending {@link SublayerBaseType}\n */\nexport type Sublayer = WMSSublayer;\nexport type SublayerTypes = Sublayer[\"type\"];\n\n/**\n * Union for all types of layers\n */\nexport type AnyLayer = Layer | Sublayer;\nexport type AnyLayerTypes = AnyLayer[\"type\"];\n\n/**\n * Type guard for checking if the layer is a {@link Sublayer}.\n */\nexport function isSublayer(layer: AnyLayer): layer is Sublayer {\n return \"parentLayer\" in layer;\n}\n\n/**\n * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).\n */\nexport function isLayer(layer: AnyLayer): layer is Layer {\n return \"olLayer\" in layer;\n}\n"],"names":[],"mappings":"AAyTO,SAAS,WAAW,KAAoC,EAAA;AAC3D,EAAA,OAAO,aAAiB,IAAA,KAAA;AAC5B;AAKO,SAAS,QAAQ,KAAiC,EAAA;AACrD,EAAA,OAAO,SAAa,IAAA,KAAA;AACxB;;;;"}
|
|
@@ -9,6 +9,7 @@ export interface AbstractLayerBaseOptions {
|
|
|
9
9
|
title: string;
|
|
10
10
|
description?: string;
|
|
11
11
|
attributes?: Record<string, unknown>;
|
|
12
|
+
internal?: boolean;
|
|
12
13
|
}
|
|
13
14
|
/**
|
|
14
15
|
* Base class for "normal" layers and sublayers alike to implement common properties
|
|
@@ -17,6 +18,8 @@ export interface AbstractLayerBaseOptions {
|
|
|
17
18
|
export declare abstract class AbstractLayerBase<AdditionalEvents = {}> extends EventEmitter<LayerBaseEvents & AdditionalEvents> implements AnyLayerBaseType {
|
|
18
19
|
#private;
|
|
19
20
|
constructor(config: AbstractLayerBaseOptions);
|
|
21
|
+
get internal(): boolean;
|
|
22
|
+
setInternal(newIsInternal: boolean): void;
|
|
20
23
|
protected get __destroyed(): boolean;
|
|
21
24
|
get map(): MapModelImpl;
|
|
22
25
|
get id(): string;
|
|
@@ -12,6 +12,7 @@ class AbstractLayerBase extends EventEmitter {
|
|
|
12
12
|
#attributesMap = reactiveMap();
|
|
13
13
|
#attributes;
|
|
14
14
|
#destroyed = false;
|
|
15
|
+
#internal;
|
|
15
16
|
constructor(config) {
|
|
16
17
|
super();
|
|
17
18
|
this.#id = config.id ?? v4();
|
|
@@ -20,10 +21,17 @@ class AbstractLayerBase extends EventEmitter {
|
|
|
20
21
|
});
|
|
21
22
|
this.#title = reactive(config.title);
|
|
22
23
|
this.#description = reactive(config.description ?? "");
|
|
24
|
+
this.#internal = reactive(config.internal ?? false);
|
|
23
25
|
if (config.attributes) {
|
|
24
26
|
this.updateAttributes(config.attributes);
|
|
25
27
|
}
|
|
26
28
|
}
|
|
29
|
+
get internal() {
|
|
30
|
+
return this.#internal.value;
|
|
31
|
+
}
|
|
32
|
+
setInternal(newIsInternal) {
|
|
33
|
+
this.#internal.value = newIsInternal;
|
|
34
|
+
}
|
|
27
35
|
get __destroyed() {
|
|
28
36
|
return this.#destroyed;
|
|
29
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractLayerBase.js","sources":["AbstractLayerBase.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n batch,\n computed,\n reactive,\n Reactive,\n reactiveMap,\n ReadonlyReactive\n} from \"@conterra/reactivity-core\";\nimport { createLogger, EventEmitter } from \"@open-pioneer/core\";\nimport { v4 as uuid4v } from \"uuid\";\nimport {\n AnyLayer,\n AnyLayerBaseType,\n AnyLayerTypes,\n ChildrenCollection,\n LayerBaseEvents,\n Sublayer\n} from \"../api\";\nimport { GroupLayer } from \"../api/layers/GroupLayer\";\nimport { GroupLayerCollectionImpl } from \"./layers/GroupLayerImpl\";\nimport { MapModelImpl } from \"./MapModelImpl\";\nimport { SublayersCollectionImpl } from \"./SublayersCollectionImpl\";\n\nconst LOG = createLogger(\"map:AbstractLayerModel\");\n\nexport interface AbstractLayerBaseOptions {\n id?: string;\n title: string;\n description?: string;\n attributes?: Record<string, unknown>;\n}\n\n/**\n * Base class for \"normal\" layers and sublayers alike to implement common properties\n * such as id, title and attributes.\n */\nexport abstract class AbstractLayerBase<AdditionalEvents = {}>\n extends EventEmitter<LayerBaseEvents & AdditionalEvents>\n implements AnyLayerBaseType\n{\n #map: MapModelImpl | undefined;\n #parent: AnyLayer | undefined;\n\n #id: string;\n #title: Reactive<string>;\n #description: Reactive<string>;\n #attributesMap = reactiveMap<string | symbol, unknown>();\n #attributes: ReadonlyReactive<Record<string | symbol, unknown>>;\n #destroyed = false;\n\n constructor(config: AbstractLayerBaseOptions) {\n super();\n this.#id = config.id ?? uuid4v();\n this.#attributes = computed(() => {\n return Object.fromEntries(this.#attributesMap.entries());\n });\n this.#title = reactive(config.title);\n this.#description = reactive(config.description ?? \"\");\n\n if (config.attributes) {\n this.updateAttributes(config.attributes);\n }\n }\n\n protected get __destroyed(): boolean {\n return this.#destroyed;\n }\n\n get map(): MapModelImpl {\n const map = this.#map;\n if (!map) {\n throw new Error(`Layer '${this.id}' has not been attached to a map yet.`);\n }\n return map;\n }\n\n get id(): string {\n return this.#id;\n }\n\n get title(): string {\n return this.#title.value;\n }\n\n get description(): string {\n return this.#description.value;\n }\n\n get attributes(): Record<string | symbol, unknown> {\n return this.#attributes.value;\n }\n\n get parent(): AnyLayer | undefined {\n return this.#parent;\n }\n\n get children(): ChildrenCollection<AnyLayer & AbstractLayerBase> | undefined {\n return this.layers ?? this.sublayers ?? undefined;\n }\n\n abstract get type(): AnyLayerTypes;\n\n abstract get visible(): boolean;\n\n abstract get layers(): GroupLayerCollectionImpl | undefined;\n\n abstract get sublayers(): SublayersCollectionImpl<Sublayer & AbstractLayerBase> | undefined;\n\n abstract get legend(): string | undefined;\n\n destroy() {\n if (this.#destroyed) {\n return;\n }\n\n this.#destroyed = true;\n this.sublayers?.destroy();\n this.layers?.destroy();\n try {\n this.emit(\"destroy\");\n } catch (e) {\n LOG.warn(`Unexpected error from event listener during layer destruction:`, e);\n }\n }\n\n /**\n * Attaches the layer to its owning map.\n */\n __attachToMap(map: MapModelImpl): void {\n if (this.#map) {\n throw new Error(\n `Layer '${this.id}' has already been attached to the map '${this.map.id}'`\n );\n }\n this.#map = map;\n }\n\n /**\n * Attach group layers to its parent group layer.\n * Called by the parent layer.\n */\n __attachToGroup(parent: GroupLayer): void {\n if (this.#parent) {\n throw new Error(\n `Layer '${this.id}' has already been attached to the group layer '${this.#parent.id}'`\n );\n }\n this.#parent = parent;\n }\n\n /**\n * Detach layer from parent group layer.\n *\n * Called by the parent group layer when destroyed or the layer gets removed.\n */\n __detachFromGroup(): void {\n this.#parent = undefined;\n }\n\n setTitle(newTitle: string): void {\n this.#title.value = newTitle;\n }\n\n setDescription(newDescription: string): void {\n this.#description.value = newDescription;\n }\n\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void {\n const keys = Reflect.ownKeys(newAttributes);\n batch(() => {\n for (const key of keys) {\n this.#attributesMap.set(key, newAttributes[key]);\n }\n });\n }\n\n deleteAttribute(deleteAttribute: string | symbol): void {\n this.#attributesMap.delete(deleteAttribute);\n }\n\n abstract setVisible(newVisibility: boolean): void;\n}\n"],"names":["uuid4v"],"mappings":";;;;AAyBA,MAAM,GAAA,GAAM,aAAa,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"AbstractLayerBase.js","sources":["AbstractLayerBase.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport {\n batch,\n computed,\n reactive,\n Reactive,\n reactiveMap,\n ReadonlyReactive\n} from \"@conterra/reactivity-core\";\nimport { createLogger, EventEmitter } from \"@open-pioneer/core\";\nimport { v4 as uuid4v } from \"uuid\";\nimport {\n AnyLayer,\n AnyLayerBaseType,\n AnyLayerTypes,\n ChildrenCollection,\n LayerBaseEvents,\n Sublayer\n} from \"../api\";\nimport { GroupLayer } from \"../api/layers/GroupLayer\";\nimport { GroupLayerCollectionImpl } from \"./layers/GroupLayerImpl\";\nimport { MapModelImpl } from \"./MapModelImpl\";\nimport { SublayersCollectionImpl } from \"./SublayersCollectionImpl\";\n\nconst LOG = createLogger(\"map:AbstractLayerModel\");\n\nexport interface AbstractLayerBaseOptions {\n id?: string;\n title: string;\n description?: string;\n attributes?: Record<string, unknown>;\n internal?: boolean;\n}\n\n/**\n * Base class for \"normal\" layers and sublayers alike to implement common properties\n * such as id, title and attributes.\n */\nexport abstract class AbstractLayerBase<AdditionalEvents = {}>\n extends EventEmitter<LayerBaseEvents & AdditionalEvents>\n implements AnyLayerBaseType\n{\n #map: MapModelImpl | undefined;\n #parent: AnyLayer | undefined;\n\n #id: string;\n #title: Reactive<string>;\n #description: Reactive<string>;\n #attributesMap = reactiveMap<string | symbol, unknown>();\n #attributes: ReadonlyReactive<Record<string | symbol, unknown>>;\n #destroyed = false;\n #internal: Reactive<boolean>;\n\n constructor(config: AbstractLayerBaseOptions) {\n super();\n this.#id = config.id ?? uuid4v();\n this.#attributes = computed(() => {\n return Object.fromEntries(this.#attributesMap.entries());\n });\n this.#title = reactive(config.title);\n this.#description = reactive(config.description ?? \"\");\n this.#internal = reactive(config.internal ?? false);\n\n if (config.attributes) {\n this.updateAttributes(config.attributes);\n }\n }\n\n get internal(): boolean {\n return this.#internal.value;\n }\n\n setInternal(newIsInternal: boolean): void {\n this.#internal.value = newIsInternal;\n }\n\n protected get __destroyed(): boolean {\n return this.#destroyed;\n }\n\n get map(): MapModelImpl {\n const map = this.#map;\n if (!map) {\n throw new Error(`Layer '${this.id}' has not been attached to a map yet.`);\n }\n return map;\n }\n\n get id(): string {\n return this.#id;\n }\n\n get title(): string {\n return this.#title.value;\n }\n\n get description(): string {\n return this.#description.value;\n }\n\n get attributes(): Record<string | symbol, unknown> {\n return this.#attributes.value;\n }\n\n get parent(): AnyLayer | undefined {\n return this.#parent;\n }\n\n get children(): ChildrenCollection<AnyLayer & AbstractLayerBase> | undefined {\n return this.layers ?? this.sublayers ?? undefined;\n }\n\n abstract get type(): AnyLayerTypes;\n\n abstract get visible(): boolean;\n\n abstract get layers(): GroupLayerCollectionImpl | undefined;\n\n abstract get sublayers(): SublayersCollectionImpl<Sublayer & AbstractLayerBase> | undefined;\n\n abstract get legend(): string | undefined;\n\n destroy() {\n if (this.#destroyed) {\n return;\n }\n\n this.#destroyed = true;\n this.sublayers?.destroy();\n this.layers?.destroy();\n try {\n this.emit(\"destroy\");\n } catch (e) {\n LOG.warn(`Unexpected error from event listener during layer destruction:`, e);\n }\n }\n\n /**\n * Attaches the layer to its owning map.\n */\n __attachToMap(map: MapModelImpl): void {\n if (this.#map) {\n throw new Error(\n `Layer '${this.id}' has already been attached to the map '${this.map.id}'`\n );\n }\n this.#map = map;\n }\n\n /**\n * Attach group layers to its parent group layer.\n * Called by the parent layer.\n */\n __attachToGroup(parent: GroupLayer): void {\n if (this.#parent) {\n throw new Error(\n `Layer '${this.id}' has already been attached to the group layer '${this.#parent.id}'`\n );\n }\n this.#parent = parent;\n }\n\n /**\n * Detach layer from parent group layer.\n *\n * Called by the parent group layer when destroyed or the layer gets removed.\n */\n __detachFromGroup(): void {\n this.#parent = undefined;\n }\n\n setTitle(newTitle: string): void {\n this.#title.value = newTitle;\n }\n\n setDescription(newDescription: string): void {\n this.#description.value = newDescription;\n }\n\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void {\n const keys = Reflect.ownKeys(newAttributes);\n batch(() => {\n for (const key of keys) {\n this.#attributesMap.set(key, newAttributes[key]);\n }\n });\n }\n\n deleteAttribute(deleteAttribute: string | symbol): void {\n this.#attributesMap.delete(deleteAttribute);\n }\n\n abstract setVisible(newVisibility: boolean): void;\n}\n"],"names":["uuid4v"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/map",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.12.0-dev.20250725080856",
|
|
5
5
|
"description": "This package integrates OpenLayers maps into an open pioneer trails application.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -14,14 +14,13 @@
|
|
|
14
14
|
"directory": "src/packages/map"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@chakra-ui/react": "^3.
|
|
17
|
+
"@chakra-ui/react": "^3.21.1",
|
|
18
18
|
"@open-pioneer/core": "^4.0.0",
|
|
19
19
|
"@open-pioneer/http": "^4.0.0",
|
|
20
20
|
"@open-pioneer/react-utils": "^4.0.0",
|
|
21
21
|
"@open-pioneer/runtime": "^4.0.0",
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"proj4": "^2.17.0",
|
|
22
|
+
"ol": "^10.6.1",
|
|
23
|
+
"proj4": "^2.19.5",
|
|
25
24
|
"react": "^19.1.0",
|
|
26
25
|
"react-dom": "^19.1.0",
|
|
27
26
|
"react-use": "^17.6.0",
|
package/projections.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import proj4 from "proj4";
|
|
2
|
+
type Proj4ProjectionDefinition = typeof proj4.defs extends infer R ? R extends (name: string) => unknown ? ReturnType<R> : never : never;
|
|
2
3
|
export type ProjectionDefinition = string | Proj4ProjectionDefinition;
|
|
3
4
|
/**
|
|
4
5
|
* Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.
|
|
@@ -25,3 +26,4 @@ export declare function registerProjections(projections: Record<string, Projecti
|
|
|
25
26
|
* Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.
|
|
26
27
|
*/
|
|
27
28
|
export declare function getProjection(name: string): Proj4ProjectionDefinition;
|
|
29
|
+
export {};
|
package/projections.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { register } from \"ol/proj/proj4\";\nimport proj4
|
|
1
|
+
{"version":3,"file":"projections.js","sources":["projections.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { register } from \"ol/proj/proj4\";\nimport proj4 from \"proj4\";\n\n// Select return type of (name: string) => ProjectionDefinition overload since ProjectionDefinition is not exported\ntype Proj4ProjectionDefinition = typeof proj4.defs extends infer R\n ? R extends (name: string) => unknown\n ? ReturnType<R>\n : never\n : never;\n\nexport type ProjectionDefinition = string | Proj4ProjectionDefinition;\n\n/**\n * Adds new registrations to the global [proj4js](https://github.com/proj4js/proj4js) definition set.\n *\n * See the proj4js documentation for more details.\n *\n * Example:\n *\n * ```ts\n * import { registerProjections } from \"@open-pioneer/map\";\n *\n * registerProjections({\n * \"EPSG:25832\": \"+proj=utm +zone=32 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs +type=crs\",\n * // ... more projections\n * });\n * ```\n *\n * @param projections\n * An object containing (key, definition) pairs. The key must be projection name (such as `\"EPSG:4326\"`).\n * The value can be a string defining the projection or an existing proj4 definition object.\n */\nexport function registerProjections(projections: Record<string, ProjectionDefinition>): void {\n for (const [name, definition] of Object.entries(projections)) {\n proj4.defs(name, definition);\n }\n register(proj4);\n}\n\n/**\n * Searches the global [proj4js](https://github.com/proj4js/proj4js) definition set for a definition with the given name.\n */\nexport function getProjection(name: string): Proj4ProjectionDefinition {\n return proj4.defs(name);\n}\n"],"names":[],"mappings":";;;AAkCO,SAAS,oBAAoB,WAAyD,EAAA;AACzF,EAAA,KAAA,MAAW,CAAC,IAAM,EAAA,UAAU,KAAK,MAAO,CAAA,OAAA,CAAQ,WAAW,CAAG,EAAA;AAC1D,IAAM,KAAA,CAAA,IAAA,CAAK,MAAM,UAAU,CAAA;AAAA;AAE/B,EAAA,QAAA,CAAS,KAAK,CAAA;AAClB;AAKO,SAAS,cAAc,IAAyC,EAAA;AACnE,EAAO,OAAA,KAAA,CAAM,KAAK,IAAI,CAAA;AAC1B;;;;"}
|