@open-pioneer/map 0.6.0 → 0.7.0

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.
Files changed (65) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +11 -0
  3. package/api/MapModel.d.ts +2 -2
  4. package/api/index.d.ts +2 -1
  5. package/api/layers/SimpleLayer.d.ts +4 -2
  6. package/api/layers/SimpleLayer.js.map +1 -1
  7. package/api/layers/WMSLayer.d.ts +5 -3
  8. package/api/layers/WMSLayer.js.map +1 -1
  9. package/api/layers/WMTSLayer.d.ts +3 -2
  10. package/api/layers/WMTSLayer.js.map +1 -1
  11. package/api/layers/base.d.ts +44 -6
  12. package/api/layers/base.js +9 -0
  13. package/api/layers/base.js.map +1 -0
  14. package/index.js +2 -0
  15. package/index.js.map +1 -1
  16. package/model/AbstractLayer.d.ts +3 -2
  17. package/model/AbstractLayer.js +1 -0
  18. package/model/AbstractLayer.js.map +1 -1
  19. package/model/AbstractLayerBase.d.ts +3 -2
  20. package/model/AbstractLayerBase.js.map +1 -1
  21. package/model/Highlights.d.ts +9 -3
  22. package/model/Highlights.js +3 -1
  23. package/model/Highlights.js.map +1 -1
  24. package/model/LayerCollectionImpl.d.ts +6 -8
  25. package/model/LayerCollectionImpl.js +12 -8
  26. package/model/LayerCollectionImpl.js.map +1 -1
  27. package/model/MapModelImpl.d.ts +4 -1
  28. package/model/SublayersCollectionImpl.d.ts +2 -2
  29. package/model/SublayersCollectionImpl.js.map +1 -1
  30. package/model/layers/SimpleLayerImpl.d.ts +3 -1
  31. package/model/layers/SimpleLayerImpl.js +3 -0
  32. package/model/layers/SimpleLayerImpl.js.map +1 -1
  33. package/model/layers/WMSLayerImpl.d.ts +2 -0
  34. package/model/layers/WMSLayerImpl.js +6 -0
  35. package/model/layers/WMSLayerImpl.js.map +1 -1
  36. package/model/layers/WMTSLayerImpl.d.ts +1 -0
  37. package/model/layers/WMTSLayerImpl.js +3 -0
  38. package/model/layers/WMTSLayerImpl.js.map +1 -1
  39. package/package.json +9 -11
  40. package/ui/CssProps.d.ts +9 -0
  41. package/ui/CssProps.js +13 -0
  42. package/ui/CssProps.js.map +1 -0
  43. package/ui/DefaultMapProvider.d.ts +39 -0
  44. package/ui/DefaultMapProvider.js +24 -0
  45. package/ui/DefaultMapProvider.js.map +1 -0
  46. package/ui/MapAnchor.d.ts +0 -3
  47. package/ui/MapAnchor.js +5 -49
  48. package/ui/MapAnchor.js.map +1 -1
  49. package/ui/MapContainer.d.ts +3 -3
  50. package/ui/MapContainer.js +30 -25
  51. package/ui/MapContainer.js.map +1 -1
  52. package/ui/MapContainerContext.d.ts +7 -0
  53. package/ui/MapContainerContext.js +17 -0
  54. package/ui/MapContainerContext.js.map +1 -0
  55. package/ui/computeMapAnchorStyles.d.ts +3 -0
  56. package/ui/computeMapAnchorStyles.js +51 -0
  57. package/ui/computeMapAnchorStyles.js.map +1 -0
  58. package/ui/styles.css +7 -0
  59. package/ui/styles.css.map +1 -1
  60. package/ui/useMapModel.d.ts +33 -6
  61. package/ui/useMapModel.js +40 -2
  62. package/ui/useMapModel.js.map +1 -1
  63. package/ui/MapContext.d.ts +0 -11
  64. package/ui/MapContext.js +0 -17
  65. package/ui/MapContext.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # @open-pioneer/map
2
2
 
3
+ ## 0.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 2502050: Introduce union types and `type` attributes for layers. This allows TypeScript narrowing for layers and determining a layer's type.
8
+
9
+ The `Layer` and `Sublayer` types for layers remain, but are unions of the corresponding concrete layer types now.
10
+ The layer type `LayerBase` has been removed and is replaced by `AnyLayerType`
11
+ to clarify that this type represents a union of all types of layer (currently `Layer` and `Sublayer`).
12
+
13
+ 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).
14
+
15
+ The following `type` attribute values have been implemented at the layers:
16
+
17
+ - SimpleLayer: `simple`
18
+ - WMSLayer: `wms`
19
+ - WMSSubLayer: `wms-sublayer`
20
+ - WMTSLayer: `wmts`
21
+
22
+ Example of usage:
23
+
24
+ ```ts
25
+ import { AnyLayer, WMTSLayer, isSublayer } from "@open-pioneer/map";
26
+
27
+ export class ExampleClass {
28
+ //...
29
+
30
+ exampleFunction(layer: AnyLayer) {
31
+ // prop may be a layer of any type
32
+
33
+ // use layers type attribute to check layer type
34
+ if (layer.type === "wmts") {
35
+ layer.matrixSet; // prop only available on WMTSLayer
36
+
37
+ const wmtsLayer: WMTSLayer = layer; // type of layer is now narrowed to `WMTSLayer`
38
+ }
39
+
40
+ // use new type guard to check if layer is a Sublayer
41
+ if (isSublayer(layer)) {
42
+ // type of layer is now narrowed to `WMSSublayer` (as it is currently the only type of Sublayer existing)
43
+ layer.parentLayer; // prop only available on Sublayers
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
50
+
51
+ ### Patch Changes
52
+
53
+ - 310800c: Update core packages version.
54
+ - 583f1d6: The `mapId` or `map` properties are now optional on individual components.
55
+ You can use the `DefaultMapProvider` to configure an implicit default value.
56
+
57
+ Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
58
+
59
+ - 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
60
+ - 397d617: Reimplement computation of map anchor positioning using new css props.
61
+ - a8b3449: Switch to a new versioning strategy.
62
+ From now on, packages released by this repository share a common version number.
63
+ - 900eb11: Update dependencies.
64
+ - 583f1d6: The new component `DefaultMapProvider` allows you to configure the _default map_ for its children.
65
+ If `DefaultMapProvider` is used, you can omit the explicit `mapId` (or `map`) property on the individual UI components.
66
+
67
+ For many applications, `DefaultMapProvider` can be used to surround all (or most of) the application's UI.
68
+
69
+ Example:
70
+
71
+ ```tsx
72
+ import { DefaultMapProvider } from "@open-pioneer/map";
73
+
74
+ <DefaultMapProvider mapId={MAP_ID}>
75
+ {/* no need to repeat the map id in this subtree, unless you want to use a different one */}
76
+ <MapContainer />
77
+ <Toc />
78
+ <ComplexChild />
79
+ </DefaultMapProvider>;
80
+ ```
81
+
82
+ - 397d617: Move attribution of OL map according to the map view's padding.
83
+
84
+ ## 0.6.1
85
+
86
+ ### Patch Changes
87
+
88
+ - b152428: Update trails dependencies
89
+ - 291ccb6: Apply layer visibility initially to be consistent with the layer configuration.
90
+
3
91
  ## 0.6.0
4
92
 
5
93
  ### Minor Changes
package/README.md CHANGED
@@ -40,6 +40,17 @@ function AppUI() {
40
40
 
41
41
  The component itself uses the map registry service to create the map using the provided `mapId`.
42
42
 
43
+ #### Changing the map view's padding
44
+
45
+ The MapContainer provides a prop `viewPadding` that allows to set the map's view padding
46
+ (see [padding property on OL View](https://openlayers.org/en/latest/apidoc/module-ol_View-View.html#padding)).
47
+ This prop musst be used to set the views padding instead of directly setting the padding on the
48
+ OL map's view to ensure that map anchor are positioned correctly.
49
+
50
+ Additionally, using the prop `viewPaddingChangeBehavior` it is possible to specify how the map behaves when the view padding changes.
51
+ Possible values are `none` (no nothing), `preserve-center`(ensures that the center point remains the same
52
+ by animating the view) and `preserve-extent` ´(ensures that the extent remains the same by zooming).
53
+
43
54
  ### Map anchor component
44
55
 
45
56
  To pass custom React components onto the map, the following anchor-points are provided:
package/api/MapModel.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { EventSource, Resource } from "@open-pioneer/core";
2
2
  import type OlMap from "ol/Map";
3
3
  import type OlBaseLayer from "ol/layer/Base";
4
4
  import type { ExtentConfig } from "./MapConfig";
5
- import type { Layer, LayerBase } from "./layers";
5
+ import type { AnyLayer, Layer } from "./layers";
6
6
  import type { LayerRetrievalOptions } from "./shared";
7
7
  import type { Geometry } from "ol/geom";
8
8
  import { BaseFeature } from "./BaseFeature";
@@ -177,7 +177,7 @@ export interface LayerCollection extends EventSource<LayerCollectionEvents> {
177
177
  /**
178
178
  * Returns the layer identified by the `id` or undefined, if no such layer exists.
179
179
  */
180
- getLayerById(id: string): LayerBase | undefined;
180
+ getLayerById(id: string): AnyLayer | undefined;
181
181
  /**
182
182
  * Returns all layers known to this collection.
183
183
  */
package/api/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { BkgTopPlusOpen, type BkgTopPlusOpenProps } from "../layers/BkgTopPlusOp
9
9
  export { useView, useProjection, useResolution, useCenter, useScale } from "../ui/hooks";
10
10
  export { MapAnchor, type MapAnchorProps, type MapAnchorPosition } from "../ui/MapAnchor";
11
11
  export { MapContainer, type MapContainerProps } from "../ui/MapContainer";
12
- export { useMapModel, type UseMapModelResult, type UseMapModelLoading, type UseMapModelResolved, type UseMapModelRejected } from "../ui/useMapModel";
12
+ export { useMapModel, type UseMapModelResult, type UseMapModelLoading, type UseMapModelResolved, type UseMapModelRejected, type MapModelProps } from "../ui/useMapModel";
13
+ export { DefaultMapProvider } from "../ui/DefaultMapProvider";
13
14
  export { calculateBufferedExtent } from "../util/geometry-utils";
14
15
  export { TOPMOST_LAYER_Z } from "../model/LayerCollectionImpl";
@@ -1,5 +1,5 @@
1
1
  import type OlBaseLayer from "ol/layer/Base";
2
- import { LayerConfig, Layer } from "./base";
2
+ import { LayerConfig, LayerBaseType } from "./base";
3
3
  /**
4
4
  * Options to construct a simple layer.
5
5
  *
@@ -20,5 +20,7 @@ export interface SimpleLayerConstructor {
20
20
  /**
21
21
  * A simple layer type wrapping an OpenLayers layer.
22
22
  */
23
- export type SimpleLayer = Layer;
23
+ export interface SimpleLayer extends LayerBaseType {
24
+ readonly type: "simple";
25
+ }
24
26
  export declare const SimpleLayer: SimpleLayerConstructor;
@@ -1 +1 @@
1
- {"version":3,"file":"SimpleLayer.js","sources":["SimpleLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport { LayerConfig, Layer } from \"./base\";\nimport { SimpleLayerImpl } from \"../../model/layers/SimpleLayerImpl\";\n\n/**\n * Options to construct a simple layer.\n *\n * Simple layers are wrappers around a custom OpenLayers layer.\n */\nexport interface SimpleLayerConfig extends LayerConfig {\n /**\n * The raw OpenLayers instance.\n */\n olLayer: OlBaseLayer;\n}\n\n/** Constructor for {@link SimpleLayer}. */\nexport interface SimpleLayerConstructor {\n prototype: SimpleLayer;\n\n /** Creates a new {@link SimpleLayer}. */\n new (config: SimpleLayerConfig): SimpleLayer;\n}\n\n/**\n * A simple layer type wrapping an OpenLayers layer.\n */\nexport type SimpleLayer = Layer;\nexport const SimpleLayer: SimpleLayerConstructor = SimpleLayerImpl;\n"],"names":[],"mappings":";;AA8BO,MAAM,WAAsC,GAAA;;;;"}
1
+ {"version":3,"file":"SimpleLayer.js","sources":["SimpleLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type OlBaseLayer from \"ol/layer/Base\";\nimport { LayerConfig, LayerBaseType } from \"./base\";\nimport { SimpleLayerImpl } from \"../../model/layers/SimpleLayerImpl\";\n\n/**\n * Options to construct a simple layer.\n *\n * Simple layers are wrappers around a custom OpenLayers layer.\n */\nexport interface SimpleLayerConfig extends LayerConfig {\n /**\n * The raw OpenLayers instance.\n */\n olLayer: OlBaseLayer;\n}\n\n/** Constructor for {@link SimpleLayer}. */\nexport interface SimpleLayerConstructor {\n prototype: SimpleLayer;\n\n /** Creates a new {@link SimpleLayer}. */\n new (config: SimpleLayerConfig): SimpleLayer;\n}\n\n/**\n * A simple layer type wrapping an OpenLayers layer.\n */\nexport interface SimpleLayer extends LayerBaseType {\n readonly type: \"simple\";\n}\n\nexport const SimpleLayer: SimpleLayerConstructor = SimpleLayerImpl;\n"],"names":[],"mappings":";;AAiCO,MAAM,WAAsC,GAAA;;;;"}
@@ -1,5 +1,5 @@
1
1
  import type { Options as WMSSourceOptions } from "ol/source/ImageWMS";
2
- import type { LayerBaseConfig, Layer, SublayersCollection, Sublayer, LayerConfig } from "./base";
2
+ import type { LayerBaseConfig, SublayersCollection, LayerConfig, LayerBaseType, SublayerBaseType } from "./base";
3
3
  /**
4
4
  * Configuration options to construct a WMS layer.
5
5
  */
@@ -29,13 +29,15 @@ export interface WMSSublayerConfig extends LayerBaseConfig {
29
29
  sublayers?: WMSSublayerConfig[];
30
30
  }
31
31
  /** Represents a WMS layer. */
32
- export interface WMSLayer extends Layer {
32
+ export interface WMSLayer extends LayerBaseType {
33
+ readonly type: "wms";
33
34
  readonly sublayers: SublayersCollection<WMSSublayer>;
34
35
  /** The URL of the WMS service that was used during layer construction. */
35
36
  readonly url: string;
36
37
  }
37
38
  /** Represents a WMS sublayer */
38
- export interface WMSSublayer extends Sublayer {
39
+ export interface WMSSublayer extends SublayerBaseType {
40
+ readonly type: "wms-sublayer";
39
41
  /**
40
42
  * The name of the WMS sublayer in the service's capabilities.
41
43
  *
@@ -1 +1 @@
1
- {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { WMSLayerImpl } from \"../../model/layers/WMSLayerImpl\";\nimport type { LayerBaseConfig, Layer, SublayersCollection, Sublayer, LayerConfig } from \"./base\";\n\n/**\n * Configuration options to construct a WMS layer.\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\n\n/**\n * Configuration options to construct the sublayers of a WMS layer.\n */\nexport interface WMSSublayerConfig extends LayerBaseConfig {\n /**\n * The name of the WMS sublayer in the service's capabilities.\n * Not mandatory, e.g. for WMS group layer. See [WMS spec](https://www.ogc.org/standard/wms/).\n */\n name?: string;\n\n /** Configuration for nested sublayers. */\n sublayers?: WMSSublayerConfig[];\n}\n\n/** Represents a WMS layer. */\nexport interface WMSLayer extends Layer {\n readonly sublayers: SublayersCollection<WMSSublayer>;\n\n /** The URL of the WMS service that was used during layer construction. */\n readonly url: string;\n}\n\n/** Represents a WMS sublayer */\nexport interface WMSSublayer extends Sublayer {\n /**\n * The name of the WMS sublayer in the service's capabilities.\n *\n * Is optional as a WMS group layer in a WMS service does not need to have a name.\n */\n readonly name: string | undefined;\n}\n\n/**\n * Constructor for {@link WMSLayer}.\n */\nexport interface WMSLayerConstructor {\n prototype: WMSLayer;\n\n /** Creates a new {@link WMSLayer}. */\n new (config: WMSLayerConfig): WMSLayer;\n}\n\nexport const WMSLayer: WMSLayerConstructor = WMSLayerImpl;\n"],"names":[],"mappings":";;AAmEO,MAAM,QAAgC,GAAA;;;;"}
1
+ {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { WMSLayerImpl } from \"../../model/layers/WMSLayerImpl\";\nimport type {\n LayerBaseConfig,\n SublayersCollection,\n LayerConfig,\n LayerBaseType,\n SublayerBaseType\n} from \"./base\";\n\n/**\n * Configuration options to construct a WMS layer.\n */\nexport interface WMSLayerConfig extends LayerConfig {\n /** URL of the WMS service. */\n url: string;\n\n /** Configures the layer's sublayers. */\n sublayers?: WMSSublayerConfig[];\n\n /**\n * Additional source options for the layer's WMS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\n\n/**\n * Configuration options to construct the sublayers of a WMS layer.\n */\nexport interface WMSSublayerConfig extends LayerBaseConfig {\n /**\n * The name of the WMS sublayer in the service's capabilities.\n * Not mandatory, e.g. for WMS group layer. See [WMS spec](https://www.ogc.org/standard/wms/).\n */\n name?: string;\n\n /** Configuration for nested sublayers. */\n sublayers?: WMSSublayerConfig[];\n}\n\n/** Represents a WMS layer. */\nexport interface WMSLayer extends LayerBaseType {\n readonly type: \"wms\";\n\n readonly sublayers: SublayersCollection<WMSSublayer>;\n\n /** The URL of the WMS service that was used during layer construction. */\n readonly url: string;\n}\n\n/** Represents a WMS sublayer */\nexport interface WMSSublayer extends SublayerBaseType {\n readonly type: \"wms-sublayer\";\n /**\n * The name of the WMS sublayer in the service's capabilities.\n *\n * Is optional as a WMS group layer in a WMS service does not need to have a name.\n */\n readonly name: string | undefined;\n}\n\n/**\n * Constructor for {@link WMSLayer}.\n */\nexport interface WMSLayerConstructor {\n prototype: WMSLayer;\n\n /** Creates a new {@link WMSLayer}. */\n new (config: WMSLayerConfig): WMSLayer;\n}\n\nexport const WMSLayer: WMSLayerConstructor = WMSLayerImpl;\n"],"names":[],"mappings":";;AA4EO,MAAM,QAAgC,GAAA;;;;"}
@@ -1,5 +1,5 @@
1
1
  import type { Options as WMSSourceOptions } from "ol/source/ImageWMS";
2
- import { Layer, LayerConfig } from "./base";
2
+ import { LayerBaseType, LayerConfig } from "./base";
3
3
  export interface WMTSLayerConfig extends LayerConfig {
4
4
  /** URL of the WMTS service. */
5
5
  url: string;
@@ -15,7 +15,8 @@ export interface WMTSLayerConfig extends LayerConfig {
15
15
  */
16
16
  sourceOptions?: Partial<WMSSourceOptions>;
17
17
  }
18
- export interface WMTSLayer extends Layer {
18
+ export interface WMTSLayer extends LayerBaseType {
19
+ readonly type: "wmts";
19
20
  /** URL of the WMTS service. */
20
21
  readonly url: string;
21
22
  /** The name of the WMTS layer in the service's capabilities. */
@@ -1 +1 @@
1
- {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { Layer, LayerConfig } from \"./base\";\nimport { WMTSLayerImpl } from \"../../model/layers/WMTSLayerImpl\";\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\nexport interface WMTSLayer extends Layer {\n /** URL of the WMTS service. */\n readonly url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n readonly name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n readonly matrixSet: string;\n}\nexport interface WMTSLayerConstructor {\n prototype: WMTSLayer;\n\n /** Creates a new {@link WMTSLayer}. */\n new (config: WMTSLayerConfig): WMTSLayer;\n}\n\nexport const WMTSLayer: WMTSLayerConstructor = WMTSLayerImpl;\n"],"names":[],"mappings":";;AAwCO,MAAM,SAAkC,GAAA;;;;"}
1
+ {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Options as WMSSourceOptions } from \"ol/source/ImageWMS\";\nimport { LayerBaseType, LayerConfig } from \"./base\";\nimport { WMTSLayerImpl } from \"../../model/layers/WMTSLayerImpl\";\nexport interface WMTSLayerConfig extends LayerConfig {\n /** URL of the WMTS service. */\n url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n matrixSet: string;\n\n /**\n * Additional source options for the layer's WMTS source.\n *\n * NOTE: These options are intended for advanced configuration:\n * the WMTS Layer manages some of the OpenLayers source options itself.\n */\n sourceOptions?: Partial<WMSSourceOptions>;\n}\nexport interface WMTSLayer extends LayerBaseType {\n readonly type: \"wmts\";\n\n /** URL of the WMTS service. */\n readonly url: string;\n\n /** The name of the WMTS layer in the service's capabilities. */\n readonly name: string;\n\n /** The name of the tile matrix set in the service's capabilities. */\n readonly matrixSet: string;\n}\nexport interface WMTSLayerConstructor {\n prototype: WMTSLayer;\n\n /** Creates a new {@link WMTSLayer}. */\n new (config: WMTSLayerConfig): WMTSLayer;\n}\n\nexport const WMTSLayer: WMTSLayerConstructor = WMTSLayerImpl;\n"],"names":[],"mappings":";;AA0CO,MAAM,SAAkC,GAAA;;;;"}
@@ -2,6 +2,9 @@ import type { EventSource } from "@open-pioneer/core";
2
2
  import type OlBaseLayer from "ol/layer/Base";
3
3
  import type { MapModel } from "../MapModel";
4
4
  import type { LayerRetrievalOptions } from "../shared";
5
+ import type { SimpleLayer } from "./SimpleLayer";
6
+ import type { WMSLayer, WMSSublayer } from "./WMSLayer";
7
+ import { WMTSLayer } from "./WMTSLayer";
5
8
  /** Events emitted by the {@link Layer} and other layer types. */
6
9
  export interface LayerBaseEvents {
7
10
  "changed": void;
@@ -16,7 +19,7 @@ export interface LayerBaseEvents {
16
19
  /** The load state of a layer. */
17
20
  export type LayerLoadState = "not-loaded" | "loading" | "loaded" | "error";
18
21
  /** Custom function to check the state of a layer and returning a "loaded" or "error". */
19
- export type HealthCheckFunction = (layer: LayerBase) => Promise<"loaded" | "error">;
22
+ export type HealthCheckFunction = (layer: Layer) => Promise<"loaded" | "error">;
20
23
  /**
21
24
  * Configuration options supported by all layer types (layers and sublayers).
22
25
  */
@@ -52,7 +55,11 @@ export interface LayerBaseConfig {
52
55
  * Instances of this interface cannot be constructed directly; use a real layer
53
56
  * class such as {@link SimpleLayer} instead.
54
57
  */
55
- export interface LayerBase<AdditionalEvents = {}> extends EventSource<LayerBaseEvents & AdditionalEvents> {
58
+ export interface AnyLayerBaseType<AdditionalEvents = {}> extends EventSource<LayerBaseEvents & AdditionalEvents> {
59
+ /**
60
+ * Identifies the type of this layer.
61
+ */
62
+ readonly type: AnyLayerTypes;
56
63
  /** The map this layer belongs to. */
57
64
  readonly map: MapModel;
58
65
  /**
@@ -74,7 +81,7 @@ export interface LayerBase<AdditionalEvents = {}> extends EventSource<LayerBaseE
74
81
  */
75
82
  readonly visible: boolean;
76
83
  /**
77
- * LegendURL from the service capabilties, if available
84
+ * LegendURL from the service capabilities, if available.
78
85
  */
79
86
  readonly legend: string | undefined;
80
87
  /**
@@ -136,7 +143,11 @@ export interface LayerConfig extends LayerBaseConfig {
136
143
  * Instances of this interface cannot be constructed directly; use a real layer
137
144
  * class such as {@link SimpleLayer} instead.
138
145
  */
139
- export interface Layer<AdditionalEvents = {}> extends LayerBase<AdditionalEvents> {
146
+ export interface LayerBaseType<AdditionalEvents = {}> extends AnyLayerBaseType<AdditionalEvents> {
147
+ /**
148
+ * Identifies the type of this layer.
149
+ */
150
+ readonly type: LayerTypes;
140
151
  /**
141
152
  * The load state of a layer.
142
153
  */
@@ -155,12 +166,16 @@ export interface Layer<AdditionalEvents = {}> extends LayerBase<AdditionalEvents
155
166
  /**
156
167
  * Represents a sublayer of another layer.
157
168
  */
158
- export interface Sublayer extends LayerBase {
169
+ export interface SublayerBaseType extends AnyLayerBaseType {
170
+ /**
171
+ * Identifies the type of this sublayer.
172
+ */
173
+ readonly type: SublayerTypes;
159
174
  /**
160
175
  * The direct parent of this layer instance.
161
176
  * This can either be the parent layer or another sublayer.
162
177
  */
163
- readonly parent: Layer | Sublayer;
178
+ readonly parent: AnyLayer;
164
179
  /**
165
180
  * The parent layer that owns this sublayer.
166
181
  */
@@ -181,3 +196,26 @@ export interface SublayersCollection<SublayerType = Sublayer> extends EventSourc
181
196
  */
182
197
  getSublayers(options?: LayerRetrievalOptions): SublayerType[];
183
198
  }
199
+ /**
200
+ * Union type for all layers (extending {@link LayerBaseType})
201
+ */
202
+ export type Layer = SimpleLayer | WMSLayer | WMTSLayer;
203
+ export type LayerTypes = Layer["type"];
204
+ /**
205
+ * Union type for all sublayers (extending {@link SublayerBaseType}
206
+ */
207
+ export type Sublayer = WMSSublayer;
208
+ export type SublayerTypes = Sublayer["type"];
209
+ /**
210
+ * Union for all types of layers
211
+ */
212
+ export type AnyLayer = Layer | Sublayer;
213
+ export type AnyLayerTypes = AnyLayer["type"];
214
+ /**
215
+ * Type guard for checking if the layer is a {@link Sublayer}.
216
+ */
217
+ export declare function isSublayer(layer: AnyLayer): layer is Sublayer;
218
+ /**
219
+ * Type guard for checking if the layer is a {@link Layer} (and not a {@link Sublayer}).
220
+ */
221
+ export declare function isLayer(layer: AnyLayer): layer is Layer;
@@ -0,0 +1,9 @@
1
+ function isSublayer(layer) {
2
+ return "parentLayer" in layer;
3
+ }
4
+ function isLayer(layer) {
5
+ return "olLayer" in layer;
6
+ }
7
+
8
+ export { isLayer, isSublayer };
9
+ //# sourceMappingURL=base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base.js","sources":["base.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 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 } from \"../shared\";\nimport type { SimpleLayer } from \"./SimpleLayer\";\nimport type { WMSLayer, WMSSublayer } from \"./WMSLayer\";\nimport { WMTSLayer } from \"./WMTSLayer\";\n\n/** Events emitted by the {@link Layer} and other layer types. */\nexport interface LayerBaseEvents {\n \"changed\": void;\n \"changed:title\": void;\n \"changed:legend\": void;\n \"changed:description\": void;\n \"changed:visible\": void;\n \"changed:attributes\": void;\n \"changed:loadState\": void;\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 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 * LegendURL from the service capabilities, if available.\n */\n readonly legend: string | undefined;\n\n /**\n * The collection of child sublayers for this layer.\n *\n * Layers that can never have any sublayers may not have a `sublayers` collection.\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 * Events emitted by the {@link SublayersCollection}.\n */\nexport interface SublayersCollectionEvents {\n changed: void;\n}\n\n/**\n * Contains the sublayers that belong to a {@link Layer} or {@link Sublayer}.\n */\nexport interface SublayersCollection<SublayerType = Sublayer>\n extends EventSource<SublayersCollectionEvents> {\n /**\n * Returns the child sublayers in this collection.\n */\n getSublayers(options?: LayerRetrievalOptions): SublayerType[];\n}\n\n/**\n * Union type for all layers (extending {@link LayerBaseType})\n */\nexport type Layer = SimpleLayer | WMSLayer | WMTSLayer;\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":"AAiQO,SAAS,WAAW,KAAoC,EAAA;AAC3D,EAAA,OAAO,aAAiB,IAAA,KAAA,CAAA;AAC5B,CAAA;AAKO,SAAS,QAAQ,KAAiC,EAAA;AACrD,EAAA,OAAO,SAAa,IAAA,KAAA,CAAA;AACxB;;;;"}
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export { isLayer, isSublayer } from './api/layers/base.js';
1
2
  export { SimpleLayer } from './api/layers/SimpleLayer.js';
2
3
  export { WMSLayer } from './api/layers/WMSLayer.js';
3
4
  export { WMTSLayer } from './api/layers/WMTSLayer.js';
@@ -7,6 +8,7 @@ export { useCenter, useProjection, useResolution, useScale, useView } from './ui
7
8
  export { MapAnchor } from './ui/MapAnchor.js';
8
9
  export { MapContainer } from './ui/MapContainer.js';
9
10
  export { useMapModel } from './ui/useMapModel.js';
11
+ export { DefaultMapProvider } from './ui/DefaultMapProvider.js';
10
12
  export { calculateBufferedExtent } from './util/geometry-utils.js';
11
13
  export { TOPMOST_LAYER_Z } from './model/LayerCollectionImpl.js';
12
14
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
1
  import OlBaseLayer from "ol/layer/Base";
2
- import { Layer, LayerLoadState, SimpleLayerConfig } from "../api";
2
+ import { LayerBaseType, LayerLoadState, SimpleLayerConfig } from "../api";
3
3
  import { AbstractLayerBase } from "./AbstractLayerBase";
4
4
  import { MapModelImpl } from "./MapModelImpl";
5
5
  /**
@@ -7,7 +7,7 @@ import { MapModelImpl } from "./MapModelImpl";
7
7
  *
8
8
  * These layers always have an associated OpenLayers layer.
9
9
  */
10
- export declare abstract class AbstractLayer<AdditionalEvents = {}> extends AbstractLayerBase<AdditionalEvents> implements Layer {
10
+ export declare abstract class AbstractLayer<AdditionalEvents = {}> extends AbstractLayerBase<AdditionalEvents> implements LayerBaseType {
11
11
  #private;
12
12
  constructor(config: SimpleLayerConfig);
13
13
  get visible(): boolean;
@@ -21,4 +21,5 @@ export declare abstract class AbstractLayer<AdditionalEvents = {}> extends Abstr
21
21
  __attach(map: MapModelImpl): void;
22
22
  setVisible(newVisibility: boolean): void;
23
23
  __setVisible(newVisibility: boolean): void;
24
+ abstract readonly type: "simple" | "wms" | "wmts";
24
25
  }
@@ -18,6 +18,7 @@ class AbstractLayer extends AbstractLayerBase {
18
18
  this.#healthCheck = config.healthCheck;
19
19
  this.#visible = config.visible ?? true;
20
20
  this.#loadState = getSourceState(getSource(this.#olLayer));
21
+ this.__setVisible(this.#visible);
21
22
  }
22
23
  get visible() {
23
24
  return this.#visible;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractLayer.js","sources":["AbstractLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport { unByKey } from \"ol/Observable\";\nimport { EventsKey } from \"ol/events\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport OlLayer from \"ol/layer/Layer\";\nimport OlSource from \"ol/source/Source\";\nimport { HealthCheckFunction, Layer, LayerConfig, LayerLoadState, SimpleLayerConfig } from \"../api\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\nimport { MapModelImpl } from \"./MapModelImpl\";\n\nconst LOG = createLogger(\"map:AbstractLayer\");\n\n/**\n * Base class for normal layer types.\n *\n * These layers always have an associated OpenLayers layer.\n */\nexport abstract class AbstractLayer<AdditionalEvents = {}>\n extends AbstractLayerBase<AdditionalEvents>\n implements Layer\n{\n #olLayer: OlBaseLayer;\n #isBaseLayer: boolean;\n #healthCheck?: string | HealthCheckFunction;\n #visible: boolean;\n\n #loadState: LayerLoadState;\n #stateWatchResource: Resource | undefined;\n\n constructor(config: SimpleLayerConfig) {\n super(config);\n this.#olLayer = config.olLayer;\n this.#isBaseLayer = config.isBaseLayer ?? false;\n this.#healthCheck = config.healthCheck;\n\n this.#visible = config.visible ?? true;\n this.#loadState = getSourceState(getSource(this.#olLayer));\n }\n\n get visible(): boolean {\n return this.#visible;\n }\n\n get olLayer(): OlBaseLayer {\n return this.#olLayer;\n }\n\n get isBaseLayer(): boolean {\n return this.#isBaseLayer;\n }\n\n get loadState(): LayerLoadState {\n return this.#loadState;\n }\n\n destroy() {\n if (this.__destroyed) {\n return;\n }\n\n this.#stateWatchResource?.destroy();\n this.olLayer.dispose();\n super.destroy();\n }\n\n /**\n * Called by the map model when the layer is added to the map.\n */\n __attach(map: MapModelImpl): void {\n super.__attachToMap(map);\n\n const { initial: initialState, resource: stateWatchResource } = watchLoadState(\n this,\n this.#healthCheck,\n (state) => {\n this.#setLoadState(state);\n }\n );\n this.#stateWatchResource = stateWatchResource;\n this.#setLoadState(initialState);\n }\n\n setVisible(newVisibility: boolean): void {\n if (this.isBaseLayer) {\n LOG.warn(\n `Cannot change visibility of base layer '${this.id}': use activateBaseLayer() on the map's LayerCollection instead.`\n );\n return;\n }\n\n this.__setVisible(newVisibility);\n }\n\n __setVisible(newVisibility: boolean): void {\n let changed = false;\n if (this.#visible !== newVisibility) {\n this.#visible = newVisibility;\n changed = true;\n }\n\n // Improvement: actual map sync?\n if (this.#olLayer.getVisible() != this.#visible) {\n this.#olLayer.setVisible(newVisibility);\n }\n changed && this.__emitChangeEvent(\"changed:visible\");\n }\n\n #setLoadState(loadState: LayerLoadState) {\n if (loadState !== this.#loadState) {\n this.#loadState = loadState;\n this.__emitChangeEvent(\"changed:loadState\");\n }\n }\n}\n\nfunction watchLoadState(\n layer: AbstractLayer,\n healthCheck: LayerConfig[\"healthCheck\"],\n onChange: (newState: LayerLoadState) => void\n): { initial: LayerLoadState; resource: Resource } {\n const olLayer = layer.olLayer;\n\n if (!(olLayer instanceof OlLayer)) {\n // Some layers don't have a source (such as group)\n return {\n initial: \"loaded\",\n resource: {\n destroy() {\n void 0;\n }\n }\n };\n }\n\n let currentSource = getSource(olLayer);\n const currentOlLayerState = getSourceState(currentSource);\n\n let currentLoadState: LayerLoadState = currentOlLayerState;\n let currentHealthState = \"loading\"; // initial state loading until health check finished\n\n // custom health check not needed when OpenLayers already returning an error state\n if (currentOlLayerState !== \"error\") {\n // health check only once during initialization\n doHealthCheck(layer, healthCheck).then((state: LayerLoadState) => {\n currentHealthState = state;\n updateState();\n });\n }\n\n const updateState = () => {\n const olLayerState = getSourceState(currentSource);\n const nextLoadState: LayerLoadState =\n currentHealthState === \"error\" ? \"error\" : olLayerState;\n\n if (currentLoadState !== nextLoadState) {\n currentLoadState = nextLoadState;\n onChange(currentLoadState);\n }\n };\n\n let stateHandle: EventsKey | undefined;\n stateHandle = currentSource?.on(\"change\", () => {\n updateState();\n });\n\n const sourceHandle = olLayer.on(\"change:source\", () => {\n // unsubscribe from old source\n stateHandle && unByKey(stateHandle);\n stateHandle = undefined;\n\n // subscribe to new source and update state\n currentSource = getSource(olLayer);\n stateHandle = currentSource?.on(\"change\", () => {\n updateState();\n });\n updateState();\n });\n return {\n initial: currentLoadState,\n resource: {\n destroy() {\n stateHandle && unByKey(stateHandle);\n unByKey(sourceHandle);\n }\n }\n };\n}\n\nasync function doHealthCheck(\n layer: AbstractLayer,\n healthCheck: LayerConfig[\"healthCheck\"]\n): Promise<LayerLoadState> {\n if (healthCheck == null) {\n return \"loaded\";\n }\n\n let healthCheckFn: HealthCheckFunction;\n if (typeof healthCheck === \"function\") {\n healthCheckFn = healthCheck;\n } else if (typeof healthCheck === \"string\") {\n healthCheckFn = async () => {\n const httpService = layer.map.__sharedDependencies.httpService;\n const response = await httpService.fetch(healthCheck);\n if (response.ok) {\n return \"loaded\";\n }\n LOG.warn(\n `Health check failed for layer '${layer.id}' (http status ${response.status})`\n );\n return \"error\";\n };\n } else {\n LOG.error(\n `Unexpected object for 'healthCheck' parameter of layer '${layer.id}'`,\n healthCheck\n );\n return \"error\";\n }\n\n try {\n return await healthCheckFn(layer);\n } catch (e) {\n LOG.warn(`Health check failed for layer '${layer.id}'`, e);\n return \"error\";\n }\n}\n\nfunction getSource(olLayer: OlLayer | OlBaseLayer) {\n if (!(olLayer instanceof OlLayer)) {\n return undefined;\n }\n return (olLayer?.getSource() as OlSource | null) ?? undefined;\n}\n\nfunction getSourceState(olSource: OlSource | undefined) {\n const state = olSource?.getState();\n switch (state) {\n case undefined:\n return \"loaded\";\n case \"undefined\":\n return \"not-loaded\";\n case \"loading\":\n return \"loading\";\n case \"ready\":\n return \"loaded\";\n case \"error\":\n return \"error\";\n }\n}\n"],"names":[],"mappings":";;;;;AAYA,MAAM,GAAA,GAAM,aAAa,mBAAmB,CAAA,CAAA;AAOrC,MAAe,sBACV,iBAEZ,CAAA;AAAA,EACI,QA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stractLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport { unByKey } from \"ol/Observable\";\nimport { EventsKey } from \"ol/events\";\nimport OlBaseLayer from \"ol/layer/Base\";\nimport OlLayer from \"ol/layer/Layer\";\nimport OlSource from \"ol/source/Source\";\nimport {\n HealthCheckFunction,\n Layer,\n LayerBaseType,\n LayerConfig,\n LayerLoadState,\n SimpleLayerConfig\n} from \"../api\";\nimport { AbstractLayerBase } from \"./AbstractLayerBase\";\nimport { MapModelImpl } from \"./MapModelImpl\";\n\nconst LOG = createLogger(\"map:AbstractLayer\");\n\n/**\n * Base class for normal layer types.\n *\n * These layers always have an associated OpenLayers layer.\n */\nexport abstract class AbstractLayer<AdditionalEvents = {}>\n extends AbstractLayerBase<AdditionalEvents>\n implements LayerBaseType\n{\n #olLayer: OlBaseLayer;\n #isBaseLayer: boolean;\n #healthCheck?: string | HealthCheckFunction;\n #visible: boolean;\n\n #loadState: LayerLoadState;\n #stateWatchResource: Resource | undefined;\n\n constructor(config: SimpleLayerConfig) {\n super(config);\n this.#olLayer = config.olLayer;\n this.#isBaseLayer = config.isBaseLayer ?? false;\n this.#healthCheck = config.healthCheck;\n\n this.#visible = config.visible ?? true;\n this.#loadState = getSourceState(getSource(this.#olLayer));\n\n this.__setVisible(this.#visible); // apply initial visibility\n }\n\n get visible(): boolean {\n return this.#visible;\n }\n\n get olLayer(): OlBaseLayer {\n return this.#olLayer;\n }\n\n get isBaseLayer(): boolean {\n return this.#isBaseLayer;\n }\n\n get loadState(): LayerLoadState {\n return this.#loadState;\n }\n\n destroy() {\n if (this.__destroyed) {\n return;\n }\n\n this.#stateWatchResource?.destroy();\n this.olLayer.dispose();\n super.destroy();\n }\n\n /**\n * Called by the map model when the layer is added to the map.\n */\n __attach(map: MapModelImpl): void {\n super.__attachToMap(map);\n\n const { initial: initialState, resource: stateWatchResource } = watchLoadState(\n this,\n this.#healthCheck,\n (state) => {\n this.#setLoadState(state);\n }\n );\n this.#stateWatchResource = stateWatchResource;\n this.#setLoadState(initialState);\n }\n\n setVisible(newVisibility: boolean): void {\n if (this.isBaseLayer) {\n LOG.warn(\n `Cannot change visibility of base layer '${this.id}': use activateBaseLayer() on the map's LayerCollection instead.`\n );\n return;\n }\n\n this.__setVisible(newVisibility);\n }\n\n __setVisible(newVisibility: boolean): void {\n let changed = false;\n if (this.#visible !== newVisibility) {\n this.#visible = newVisibility;\n changed = true;\n }\n\n // Improvement: actual map sync?\n if (this.#olLayer.getVisible() != this.#visible) {\n this.#olLayer.setVisible(newVisibility);\n }\n changed && this.__emitChangeEvent(\"changed:visible\");\n }\n\n #setLoadState(loadState: LayerLoadState) {\n if (loadState !== this.#loadState) {\n this.#loadState = loadState;\n this.__emitChangeEvent(\"changed:loadState\");\n }\n }\n\n abstract readonly type: \"simple\" | \"wms\" | \"wmts\";\n}\n\nfunction watchLoadState(\n layer: AbstractLayer,\n healthCheck: LayerConfig[\"healthCheck\"],\n onChange: (newState: LayerLoadState) => void\n): { initial: LayerLoadState; resource: Resource } {\n const olLayer = layer.olLayer;\n\n if (!(olLayer instanceof OlLayer)) {\n // Some layers don't have a source (such as group)\n return {\n initial: \"loaded\",\n resource: {\n destroy() {\n void 0;\n }\n }\n };\n }\n\n let currentSource = getSource(olLayer);\n const currentOlLayerState = getSourceState(currentSource);\n\n let currentLoadState: LayerLoadState = currentOlLayerState;\n let currentHealthState = \"loading\"; // initial state loading until health check finished\n\n // custom health check not needed when OpenLayers already returning an error state\n if (currentOlLayerState !== \"error\") {\n // health check only once during initialization\n doHealthCheck(layer, healthCheck).then((state: LayerLoadState) => {\n currentHealthState = state;\n updateState();\n });\n }\n\n const updateState = () => {\n const olLayerState = getSourceState(currentSource);\n const nextLoadState: LayerLoadState =\n currentHealthState === \"error\" ? \"error\" : olLayerState;\n\n if (currentLoadState !== nextLoadState) {\n currentLoadState = nextLoadState;\n onChange(currentLoadState);\n }\n };\n\n let stateHandle: EventsKey | undefined;\n stateHandle = currentSource?.on(\"change\", () => {\n updateState();\n });\n\n const sourceHandle = olLayer.on(\"change:source\", () => {\n // unsubscribe from old source\n stateHandle && unByKey(stateHandle);\n stateHandle = undefined;\n\n // subscribe to new source and update state\n currentSource = getSource(olLayer);\n stateHandle = currentSource?.on(\"change\", () => {\n updateState();\n });\n updateState();\n });\n return {\n initial: currentLoadState,\n resource: {\n destroy() {\n stateHandle && unByKey(stateHandle);\n unByKey(sourceHandle);\n }\n }\n };\n}\n\nasync function doHealthCheck(\n layer: AbstractLayer,\n healthCheck: LayerConfig[\"healthCheck\"]\n): Promise<LayerLoadState> {\n if (healthCheck == null) {\n return \"loaded\";\n }\n\n let healthCheckFn: HealthCheckFunction;\n if (typeof healthCheck === \"function\") {\n healthCheckFn = healthCheck;\n } else if (typeof healthCheck === \"string\") {\n healthCheckFn = async () => {\n const httpService = layer.map.__sharedDependencies.httpService;\n const response = await httpService.fetch(healthCheck);\n if (response.ok) {\n return \"loaded\";\n }\n LOG.warn(\n `Health check failed for layer '${layer.id}' (http status ${response.status})`\n );\n return \"error\";\n };\n } else {\n LOG.error(\n `Unexpected object for 'healthCheck' parameter of layer '${layer.id}'`,\n healthCheck\n );\n return \"error\";\n }\n\n try {\n return await healthCheckFn(layer as Layer);\n } catch (e) {\n LOG.warn(`Health check failed for layer '${layer.id}'`, e);\n return \"error\";\n }\n}\n\nfunction getSource(olLayer: OlLayer | OlBaseLayer) {\n if (!(olLayer instanceof OlLayer)) {\n return undefined;\n }\n return (olLayer?.getSource() as OlSource | null) ?? undefined;\n}\n\nfunction getSourceState(olSource: OlSource | undefined) {\n const state = olSource?.getState();\n switch (state) {\n case undefined:\n return \"loaded\";\n case \"undefined\":\n return \"not-loaded\";\n case \"loading\":\n return \"loading\";\n case \"ready\":\n return \"loaded\";\n case \"error\":\n return \"error\";\n }\n}\n"],"names":[],"mappings":";;;;;AAmBA,MAA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K,OAAA;AACD,MAAO,OAAA,QAAA,CAAA;AAAA,IACX,KAAK,OAAA;AACD,MAAO,OAAA,OAAA,CAAA;AAAA,GACf;AACJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter, EventNames } from "@open-pioneer/core";
2
- import { LayerBase, LayerBaseEvents, Sublayer } from "../api";
2
+ import { AnyLayerBaseType, AnyLayerTypes, LayerBaseEvents, Sublayer } from "../api";
3
3
  import { MapModelImpl } from "./MapModelImpl";
4
4
  import { SublayersCollectionImpl } from "./SublayersCollectionImpl";
5
5
  export interface AbstractLayerBaseOptions {
@@ -12,7 +12,7 @@ export interface AbstractLayerBaseOptions {
12
12
  * Base class for "normal" layers and sublayers alike to implement common properties
13
13
  * such as id, title and attributes.
14
14
  */
15
- export declare abstract class AbstractLayerBase<AdditionalEvents = {}> extends EventEmitter<LayerBaseEvents & AdditionalEvents> implements LayerBase {
15
+ export declare abstract class AbstractLayerBase<AdditionalEvents = {}> extends EventEmitter<LayerBaseEvents & AdditionalEvents> implements AnyLayerBaseType {
16
16
  #private;
17
17
  constructor(config: AbstractLayerBaseOptions);
18
18
  protected get __destroyed(): boolean;
@@ -21,6 +21,7 @@ export declare abstract class AbstractLayerBase<AdditionalEvents = {}> extends E
21
21
  get title(): string;
22
22
  get description(): string;
23
23
  get attributes(): Record<string | symbol, unknown>;
24
+ abstract get type(): AnyLayerTypes;
24
25
  abstract get visible(): boolean;
25
26
  abstract get sublayers(): SublayersCollectionImpl<Sublayer & AbstractLayerBase> | undefined;
26
27
  abstract get legend(): string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractLayerBase.js","sources":["AbstractLayerBase.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, EventNames, createLogger } from \"@open-pioneer/core\";\nimport { v4 as uuid4v } from \"uuid\";\nimport { LayerBase, LayerBaseEvents, Sublayer } from \"../api\";\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 LayerBase\n{\n #map: MapModelImpl | undefined;\n\n #id: string;\n #title: string;\n #description: string;\n #attributes: Record<string | symbol, unknown>;\n #destroyed = false;\n\n constructor(config: AbstractLayerBaseOptions) {\n super();\n this.#id = config.id ?? uuid4v();\n this.#attributes = config.attributes ?? {};\n this.#title = config.title;\n this.#description = config.description ?? \"\";\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;\n }\n\n get description(): string {\n return this.#description;\n }\n\n get attributes(): Record<string | symbol, unknown> {\n return this.#attributes;\n }\n\n abstract get visible(): boolean;\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 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 protected __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 setTitle(newTitle: string): void {\n if (newTitle !== this.#title) {\n this.#title = newTitle;\n this.__emitChangeEvent(\"changed:title\");\n }\n }\n\n setDescription(newDescription: string): void {\n if (newDescription !== this.#description) {\n this.#description = newDescription;\n this.__emitChangeEvent(\"changed:description\");\n }\n }\n\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void {\n const attributes = this.#attributes;\n const keys = Reflect.ownKeys(newAttributes);\n\n let changed = false;\n for (const key of keys) {\n const existing = attributes[key];\n const value = newAttributes[key];\n if (existing !== value) {\n attributes[key] = value;\n changed = true;\n }\n }\n\n if (changed) {\n this.__emitChangeEvent(\"changed:attributes\");\n }\n }\n\n deleteAttribute(deleteAttribute: string | symbol): void {\n const attributes = this.#attributes;\n if (attributes[deleteAttribute]) {\n delete attributes[deleteAttribute];\n this.__emitChangeEvent(\"changed:attributes\");\n }\n }\n\n abstract setVisible(newVisibility: boolean): void;\n\n protected __emitChangeEvent<Name extends EventNames<LayerBaseEvents & AdditionalEvents>>(\n event: Name\n ) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this as any).emit(event);\n this.emit(\"changed\");\n }\n}\n"],"names":["uuid4v"],"mappings":";;;AAQA,MAAM,GAAA,GAAM,aAAa,wBAAwB,CAAA,CAAA;AAa1C,MAAe,0BACV,YAEZ,CAAA;AAAA,EACI,IAAA,CAAA;AAAA,EAEA,GAAA,CAAA;AAAA,EACA,MAAA,CAAA;AAAA,EACA,YAAA,CAAA;AAAA,EACA,WAAA,CAAA;AAAA,EACA,UAAa,GAAA,KAAA,CAAA;AAAA,EAEb,YAAY,MAAkC,EAAA;AAC1C,IAAM,KAAA,EAAA,CAAA;AACN,IAAK,IAAA,CAAA,GAAA,GAAM,MAAO,CAAA,EAAA,IAAMA,EAAO,EAAA,CAAA;AAC/B,IAAK,IAAA,CAAA,WAAA,GAAc,MAAO,CAAA,UAAA,IAAc,EAAC,CAAA;AACzC,IAAA,IAAA,CAAK,SAAS,MAAO,CAAA,KAAA,CAAA;AACrB,IAAK,IAAA,CAAA,YAAA,GAAe,OAAO,WAAe,IAAA,EAAA,CAA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A,WAAA,CAAA;AACxB,IAAI,IAAA,UAAA,CAAW,eAAe,CAAG,EAAA;AAC7B,MAAA,OAAO,WAAW,eAAe,CAAA,CAAA;AACjC,MAAA,IAAA,CAAK,kBAAkB,oBAAoB,CAAA,CAAA;AAAA,KAC/C;AAAA,GACJ;AAAA,EAIU,kBACN,KACF,EAAA;AAEE,IAAC,IAAA,CAAa,KAAK,KAAK,CAAA,CAAA;AACxB,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA,CAAA;AAAA,GACvB;AACJ;;;;"}
1
+ {"version":3,"file":"AbstractLayerBase.js","sources":["AbstractLayerBase.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { EventEmitter, EventNames, createLogger } from \"@open-pioneer/core\";\nimport { v4 as uuid4v } from \"uuid\";\nimport { AnyLayerBaseType, AnyLayerTypes, LayerBaseEvents, Sublayer } from \"../api\";\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\n #id: string;\n #title: string;\n #description: string;\n #attributes: Record<string | symbol, unknown>;\n #destroyed = false;\n\n constructor(config: AbstractLayerBaseOptions) {\n super();\n this.#id = config.id ?? uuid4v();\n this.#attributes = config.attributes ?? {};\n this.#title = config.title;\n this.#description = config.description ?? \"\";\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;\n }\n\n get description(): string {\n return this.#description;\n }\n\n get attributes(): Record<string | symbol, unknown> {\n return this.#attributes;\n }\n\n abstract get type(): AnyLayerTypes;\n\n abstract get visible(): boolean;\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 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 protected __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 setTitle(newTitle: string): void {\n if (newTitle !== this.#title) {\n this.#title = newTitle;\n this.__emitChangeEvent(\"changed:title\");\n }\n }\n\n setDescription(newDescription: string): void {\n if (newDescription !== this.#description) {\n this.#description = newDescription;\n this.__emitChangeEvent(\"changed:description\");\n }\n }\n\n updateAttributes(newAttributes: Record<string | symbol, unknown>): void {\n const attributes = this.#attributes;\n const keys = Reflect.ownKeys(newAttributes);\n\n let changed = false;\n for (const key of keys) {\n const existing = attributes[key];\n const value = newAttributes[key];\n if (existing !== value) {\n attributes[key] = value;\n changed = true;\n }\n }\n\n if (changed) {\n this.__emitChangeEvent(\"changed:attributes\");\n }\n }\n\n deleteAttribute(deleteAttribute: string | symbol): void {\n const attributes = this.#attributes;\n if (attributes[deleteAttribute]) {\n delete attributes[deleteAttribute];\n this.__emitChangeEvent(\"changed:attributes\");\n }\n }\n\n abstract setVisible(newVisibility: boolean): void;\n\n protected __emitChangeEvent<Name extends EventNames<LayerBaseEvents & AdditionalEvents>>(\n event: Name\n ) {\n // eslint-disable-next-line @typescript-eslint/no-expl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AAA,MAAM,aAAa,IAAK,CAAA,WAAA,CAAA;AACxB,IAAM,MAAA,IAAA,GAAO,OAAQ,CAAA,OAAA,CAAQ,aAAa,CAAA,CAAA;AAE1C,IAAA,IAAI,OAAU,GAAA,KAAA,CAAA;AACd,IAAA,KAAA,MAAW,OAAO,IAAM,EAAA;AACpB,MAAM,MAAA,QAAA,GAAW,WAAW,GAAG,CAAA,CAAA;AAC/B,MAAM,MAAA,KAAA,GAAQ,cAAc,GAAG,CAAA,CAAA;AAC/B,MAAA,IAAI,aAAa,KAAO,EAAA;AACpB,QAAA,UAAA,CAAW,GAAG,CAAI,GAAA,KAAA,CAAA;AAClB,QAAU,OAAA,GAAA,IAAA,CAAA;AAAA,OACd;AAAA,KACJ;AAEA,IAAA,IAAI,OAAS,EAAA;AACT,MAAA,IAAA,CAAK,kBAAkB,oBAAoB,CAAA,CAAA;AAAA,KAC/C;AAAA,GACJ;AAAA,EAEA,gBAAgB,eAAwC,EAAA;AACpD,IAAA,MAAM,aAAa,IAAK,CAAA,WAAA,CAAA;AACxB,IAAI,IAAA,UAAA,CAAW,eAAe,CAAG,EAAA;AAC7B,MAAA,OAAO,WAAW,eAAe,CAAA,CAAA;AACjC,MAAA,IAAA,CAAK,kBAAkB,oBAAoB,CAAA,CAAA;AAAA,KAC/C;AAAA,GACJ;AAAA,EAIU,kBACN,KACF,EAAA;AAEE,IAAC,IAAA,CAAa,KAAK,KAAK,CAAA,CAAA;AACxB,IAAA,IAAA,CAAK,KAAK,SAAS,CAAA,CAAA;AAAA,GACvB;AACJ;;;;"}
@@ -2,7 +2,7 @@ import { Feature } from "ol";
2
2
  import OlMap from "ol/Map";
3
3
  import { Geometry } from "ol/geom";
4
4
  import VectorLayer from "ol/layer/Vector";
5
- import { DisplayTarget, Highlight, HighlightOptions, HighlightZoomOptions, ZoomOptions } from "../api/MapModel";
5
+ import { DisplayTarget, HighlightOptions, HighlightZoomOptions, ZoomOptions } from "../api/MapModel";
6
6
  export declare class Highlights {
7
7
  #private;
8
8
  private olMap;
@@ -22,7 +22,10 @@ export declare class Highlights {
22
22
  /**
23
23
  * This method displays geometries or BaseFeatures with optional styling in the map
24
24
  */
25
- addHighlight(displayTarget: DisplayTarget[], highlightOptions: HighlightOptions | undefined): Highlight;
25
+ addHighlight(displayTarget: DisplayTarget[], highlightOptions: HighlightOptions | undefined): {
26
+ readonly isActive: boolean;
27
+ destroy(): void;
28
+ };
26
29
  /**
27
30
  * This method zoom to geometries or BaseFeatures
28
31
  */
@@ -30,6 +33,9 @@ export declare class Highlights {
30
33
  /**
31
34
  * This method displays geometries or BaseFeatures with optional styling in the map and executed a zoom
32
35
  */
33
- addHighlightAndZoom(displayTarget: DisplayTarget[], highlightZoomStyle: HighlightZoomOptions | undefined): Highlight;
36
+ addHighlightAndZoom(displayTarget: DisplayTarget[], highlightZoomStyle: HighlightZoomOptions | undefined): {
37
+ readonly isActive: boolean;
38
+ destroy(): void;
39
+ };
34
40
  clearHighlight(): void;
35
41
  }
@@ -19,10 +19,12 @@ import 'react/jsx-runtime';
19
19
  import '@open-pioneer/chakra-integration';
20
20
  import '@open-pioneer/react-utils';
21
21
  import 'react-dom';
22
- import '../ui/MapContext.js';
22
+ import '../ui/MapContainerContext.js';
23
23
  import '../ui/MapContainer.js';
24
24
  import '@open-pioneer/runtime/react-integration';
25
25
  import 'react-use';
26
+ import './MapModelImpl.js';
27
+ import '../ui/DefaultMapProvider.js';
26
28
  import { TOPMOST_LAYER_Z } from './LayerCollectionImpl.js';
27
29
 
28
30
  const DEFAULT_OL_POINT_ZOOM_LEVEL = 17;