@open-pioneer/map 0.9.0-dev.20250220091855 → 0.9.0-dev.20250224083536

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 (44) hide show
  1. package/CHANGELOG.md +117 -92
  2. package/MapRegistryImpl.js.map +1 -1
  3. package/README.md +29 -29
  4. package/api/BaseFeature.d.ts +6 -2
  5. package/api/index.d.ts +0 -1
  6. package/api/layers/GroupLayer.js.map +1 -1
  7. package/api/layers/SimpleLayer.js.map +1 -1
  8. package/api/layers/WMSLayer.js.map +1 -1
  9. package/api/layers/WMTSLayer.js.map +1 -1
  10. package/api/layers/base.js.map +1 -1
  11. package/index.js +0 -1
  12. package/index.js.map +1 -1
  13. package/model/AbstractLayer.js.map +1 -1
  14. package/model/AbstractLayerBase.js.map +1 -1
  15. package/model/Highlights.js +1 -3
  16. package/model/Highlights.js.map +1 -1
  17. package/model/LayerCollectionImpl.js +3 -3
  18. package/model/LayerCollectionImpl.js.map +1 -1
  19. package/model/MapModelImpl.js.map +1 -1
  20. package/model/SublayersCollectionImpl.js.map +1 -1
  21. package/model/createMapModel.js.map +1 -1
  22. package/model/getRecursiveLayers.js.map +1 -1
  23. package/model/layers/GroupLayerImpl.js.map +1 -1
  24. package/model/layers/SimpleLayerImpl.js.map +1 -1
  25. package/model/layers/WMSLayerImpl.js.map +1 -1
  26. package/model/layers/WMTSLayerImpl.js.map +1 -1
  27. package/package.json +10 -10
  28. package/projections.js.map +1 -1
  29. package/ui/CssProps.js.map +1 -1
  30. package/ui/DefaultMapProvider.js.map +1 -1
  31. package/ui/MapAnchor.d.ts +1 -1
  32. package/ui/MapAnchor.js.map +1 -1
  33. package/ui/MapContainer.js +1 -1
  34. package/ui/MapContainer.js.map +1 -1
  35. package/ui/MapContainerContext.js.map +1 -1
  36. package/ui/computeMapAnchorStyles.js.map +1 -1
  37. package/ui/hooks.js.map +1 -1
  38. package/ui/useMapModel.js.map +1 -1
  39. package/util/capabilities-utils.js.map +1 -1
  40. package/util/geometry-utils.js.map +1 -1
  41. package/util/ol-test-support.js.map +1 -1
  42. package/layers/BkgTopPlusOpen.d.ts +0 -21
  43. package/layers/BkgTopPlusOpen.js +0 -61
  44. package/layers/BkgTopPlusOpen.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,13 +1,14 @@
1
1
  # @open-pioneer/map
2
2
 
3
- ## 0.9.0-dev.20250220091855
3
+ ## 0.9.0-dev.20250224083536
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - f327eec: Deprecate `mapModel.layers.getAllLayers()`.
8
- Use `mapModel.layers.getLayers()` instead.
9
- The name of `getAllLayers()` is misleading because it does not recurse into nested layers.
10
- - f327eec: Add function `getRecursiveLayers()` to `LayerCollection`, `SublayerCollection` and `GroupLayerCollection` in `@open-pioneer/map`
7
+ - cb94c75: update dependencies
8
+ - f327eec: Deprecate `mapModel.layers.getAllLayers()`.
9
+ Use `mapModel.layers.getLayers()` instead.
10
+ The name of `getAllLayers()` is misleading because it does not recurse into nested layers.
11
+ - f327eec: Add function `getRecursiveLayers()` to `LayerCollection`, `SublayerCollection` and `GroupLayerCollection` in `@open-pioneer/map`
11
12
 
12
13
  Compared to `getLayers` and `getOperationalLayers`, `getRecursiveLayer` returns all (nested) child and sub layers of a collection.
13
14
  The property `options.filter` can be used to exclude layers (and their child layers) from the result. For `LayerCollection`, `getRecursiveLayers()` provides the predefined filters `base` and `operational` to return either base layers or operation layers only.
@@ -49,15 +50,39 @@
49
50
 
50
51
  ### Patch Changes
51
52
 
52
- - 209eb8e: Added a configuration option to disable fetching of WMS service capabilities.
53
+ - 37cd707: Add a generic type parameter `PropertiesType` to the `BaseFeature` interface.
54
+ This allows specifying the type of the `properties` attribute.
55
+ The default type is `Readonly<Record<string, unknown>>` for backwards compatibility.
56
+
57
+ Example:
58
+
59
+ ```ts
60
+ interface MyFeatureProperties {
61
+ name: string;
62
+ }
63
+
64
+ const feature: BaseFeature<MyFeatureProperties> = {
65
+ id: 123,
66
+ properties: {
67
+ name: "Example Feature"
68
+ }
69
+ };
70
+
71
+ // string | undefined instead of `unknown`
72
+ const name = feature.properties?.name;
73
+ ```
74
+
75
+ - 32ed2cd: Fix `mapModel.layers.getLayerById()` not being reactive (#400).
76
+ - 209eb8e: Added a configuration option to disable fetching of WMS service capabilities.
77
+ - d72e42c: Removed BKGTopPlusOpen layer source. The BKGTopPlusOpen was an internal layer source only needed for tests. Please use own test sources instead.
53
78
 
54
79
  ## 0.8.0
55
80
 
56
81
  ### Minor Changes
57
82
 
58
- - b717121: Update from OL 9 to OL 10.
59
- - e7978a8: **Breaking:** Remove most events from the map model and the layer interfaces.
60
- All events that were merely used to synchronized state (e.g. `changed:title` etc.) have been removed.
83
+ - b717121: Update from OL 9 to OL 10.
84
+ - e7978a8: **Breaking:** Remove most events from the map model and the layer interfaces.
85
+ All events that were merely used to synchronized state (e.g. `changed:title` etc.) have been removed.
61
86
 
62
87
  The map model and related objects (layers, layer collections, etc.) are now based on the [Reactivity API](https://github.com/conterra/reactivity/blob/main/packages/reactivity-core/README.md).
63
88
  This change greatly simplifies the code that is necessary to access up-to-date values and to react to changes.
@@ -93,18 +118,18 @@
93
118
 
94
119
  For more details, check the [Reactivity API documentation](https://github.com/conterra/reactivity/blob/main/packages/reactivity-core/README.md).
95
120
 
96
- - 7ae9f90: Add new `children` property to all layers.
97
- This property makes it possible to handle any layer children in a generic fashion, regardless of the layer's actual type.
121
+ - 7ae9f90: Add new `children` property to all layers.
122
+ This property makes it possible to handle any layer children in a generic fashion, regardless of the layer's actual type.
98
123
 
99
124
  `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.
100
125
 
101
- - d8337a6: The following hooks are deprecated and will be removed in a future release:
126
+ - d8337a6: The following hooks are deprecated and will be removed in a future release:
102
127
 
103
- - `useView`
104
- - `useProjection`
105
- - `useResolution`
106
- - `useCenter`
107
- - `useScale`
128
+ - `useView`
129
+ - `useProjection`
130
+ - `useResolution`
131
+ - `useCenter`
132
+ - `useScale`
108
133
 
109
134
  They can all be replaced by using the new reactive properties on the `MapModel`, for example:
110
135
 
@@ -116,13 +141,13 @@
116
141
  const center = useReactiveSnapshot(() => mapModel.center, [mapModel]);
117
142
  ```
118
143
 
119
- - 2fa8020: Update trails core package dependencies.
144
+ - 2fa8020: Update trails core package dependencies.
120
145
 
121
- - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
122
- - Removes any obsolete references to `@chakra-ui/system`.
123
- This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
146
+ - Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
147
+ - Removes any obsolete references to `@chakra-ui/system`.
148
+ This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
124
149
 
125
- - 7ae9f90: Add new layer type `GroupLayer` to to the Map API.
150
+ - 7ae9f90: Add new layer type `GroupLayer` to to the Map API.
126
151
 
127
152
  A `GroupLayer` contains a list of `Layer` (e.g. `SimpleLayer` or `WMSLayer`). Because `GroupLayer` is a `Layer` as well nested groups are supported.
128
153
  The child layers of a `GroupLayer` can be accessed with the `layers` property - `layers` is `undefined` if it is not a group.
@@ -166,14 +191,14 @@
166
191
  Layers can only be added to a single group or map.
167
192
  Sublayers (e.g. `WMSSublayer`) cannot be added to a group directly.
168
193
 
169
- - d8337a6: Provide new reactive properties on the `MapModel` type.
194
+ - d8337a6: Provide new reactive properties on the `MapModel` type.
170
195
 
171
- - `olView` (-> `olMap.getView()`)
172
- - `projection` (-> `olMap.getView().getProjection()`)
173
- - `resolution` (-> `olMap.getView().getResolution()`)
174
- - `zoomLevel` (-> `olMap.getView().getZoom()`)
175
- - `center` (-> `olMap.getView().getCenter()`)
176
- - `scale` (derived from center and resolution)
196
+ - `olView` (-> `olMap.getView()`)
197
+ - `projection` (-> `olMap.getView().getProjection()`)
198
+ - `resolution` (-> `olMap.getView().getResolution()`)
199
+ - `zoomLevel` (-> `olMap.getView().getZoom()`)
200
+ - `center` (-> `olMap.getView().getCenter()`)
201
+ - `scale` (derived from center and resolution)
177
202
 
178
203
  Most of the listed properties are already available on raw OpenLayers objects (see code in parentheses above).
179
204
  However, those OpenLayers properties require manual work for synchronization, whereas the new properties are reactive (and can be watched, for example, using `useReactiveSnapshot()`).
@@ -182,15 +207,15 @@
182
207
 
183
208
  ### Patch Changes
184
209
 
185
- - 7a5f1e1: Fix keyboard events from map anchors after update to OpenLayers 10.
186
- - 49f0207: Update trails core packages to version 2.4.0
187
- - b2127df: Improve documentation of layers in README
210
+ - 7a5f1e1: Fix keyboard events from map anchors after update to OpenLayers 10.
211
+ - 49f0207: Update trails core packages to version 2.4.0
212
+ - b2127df: Improve documentation of layers in README
188
213
 
189
214
  ## 0.7.0
190
215
 
191
216
  ### Minor Changes
192
217
 
193
- - 2502050: Introduce union types and `type` attributes for layers. This allows TypeScript narrowing for layers and determining a layer's type.
218
+ - 2502050: Introduce union types and `type` attributes for layers. This allows TypeScript narrowing for layers and determining a layer's type.
194
219
 
195
220
  The `Layer` and `Sublayer` types for layers remain, but are unions of the corresponding concrete layer types now.
196
221
  The layer type `LayerBase` has been removed and is replaced by `AnyLayerType`
@@ -200,10 +225,10 @@
200
225
 
201
226
  The following `type` attribute values have been implemented at the layers:
202
227
 
203
- - SimpleLayer: `simple`
204
- - WMSLayer: `wms`
205
- - WMSSubLayer: `wms-sublayer`
206
- - WMTSLayer: `wmts`
228
+ - SimpleLayer: `simple`
229
+ - WMSLayer: `wms`
230
+ - WMSSubLayer: `wms-sublayer`
231
+ - WMTSLayer: `wmts`
207
232
 
208
233
  Example of usage:
209
234
 
@@ -232,23 +257,23 @@
232
257
  }
233
258
  ```
234
259
 
235
- - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
260
+ - 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
236
261
 
237
262
  ### Patch Changes
238
263
 
239
- - 310800c: Update core packages version.
240
- - 583f1d6: The `mapId` or `map` properties are now optional on individual components.
241
- You can use the `DefaultMapProvider` to configure an implicit default value.
264
+ - 310800c: Update core packages version.
265
+ - 583f1d6: The `mapId` or `map` properties are now optional on individual components.
266
+ You can use the `DefaultMapProvider` to configure an implicit default value.
242
267
 
243
268
  Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
244
269
 
245
- - 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
246
- - 397d617: Reimplement computation of map anchor positioning using new css props.
247
- - a8b3449: Switch to a new versioning strategy.
248
- From now on, packages released by this repository share a common version number.
249
- - 900eb11: Update dependencies.
250
- - 583f1d6: The new component `DefaultMapProvider` allows you to configure the _default map_ for its children.
251
- If `DefaultMapProvider` is used, you can omit the explicit `mapId` (or `map`) property on the individual UI components.
270
+ - 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
271
+ - 397d617: Reimplement computation of map anchor positioning using new css props.
272
+ - a8b3449: Switch to a new versioning strategy.
273
+ From now on, packages released by this repository share a common version number.
274
+ - 900eb11: Update dependencies.
275
+ - 583f1d6: The new component `DefaultMapProvider` allows you to configure the _default map_ for its children.
276
+ If `DefaultMapProvider` is used, you can omit the explicit `mapId` (or `map`) property on the individual UI components.
252
277
 
253
278
  For many applications, `DefaultMapProvider` can be used to surround all (or most of) the application's UI.
254
279
 
@@ -265,20 +290,20 @@
265
290
  </DefaultMapProvider>;
266
291
  ```
267
292
 
268
- - 397d617: Move attribution of OL map according to the map view's padding.
293
+ - 397d617: Move attribution of OL map according to the map view's padding.
269
294
 
270
295
  ## 0.6.1
271
296
 
272
297
  ### Patch Changes
273
298
 
274
- - b152428: Update trails dependencies
275
- - 291ccb6: Apply layer visibility initially to be consistent with the layer configuration.
299
+ - b152428: Update trails dependencies
300
+ - 291ccb6: Apply layer visibility initially to be consistent with the layer configuration.
276
301
 
277
302
  ## 0.6.0
278
303
 
279
304
  ### Minor Changes
280
305
 
281
- - 0d51d2f: Change how map anchors are positioned in the DOM.
306
+ - 0d51d2f: Change how map anchors are positioned in the DOM.
282
307
 
283
308
  Previously, map anchor divs were children of the OpenLayers map viewport:
284
309
 
@@ -313,95 +338,95 @@
313
338
 
314
339
  ### Patch Changes
315
340
 
316
- - 28e092a: Update dependencies
317
- - 76f8863: Add a new (internal) entry point to support the map-test-utils package.
341
+ - 28e092a: Update dependencies
342
+ - 76f8863: Add a new (internal) entry point to support the map-test-utils package.
318
343
 
319
344
  ## 0.5.1
320
345
 
321
346
  ### Patch Changes
322
347
 
323
- - 4140646: Update trails dependencies
324
- - 4140646: Update to react 18.3.1
325
- - b5bb7a1: Adjusted name of Open Pioneer project to Open Pioneer Trails
326
- - 81bc7da: Update trails dependencies
327
- - 2c092dc: Update dependencies
328
- - Updated dependencies [4140646]
329
- - Updated dependencies [4140646]
330
- - Updated dependencies [81bc7da]
331
- - Updated dependencies [2c092dc]
332
- - Updated dependencies [4140646]
333
- - @open-pioneer/react-utils@0.2.3
348
+ - 4140646: Update trails dependencies
349
+ - 4140646: Update to react 18.3.1
350
+ - b5bb7a1: Adjusted name of Open Pioneer project to Open Pioneer Trails
351
+ - 81bc7da: Update trails dependencies
352
+ - 2c092dc: Update dependencies
353
+ - Updated dependencies [4140646]
354
+ - Updated dependencies [4140646]
355
+ - Updated dependencies [81bc7da]
356
+ - Updated dependencies [2c092dc]
357
+ - Updated dependencies [4140646]
358
+ - @open-pioneer/react-utils@0.2.3
334
359
 
335
360
  ## 0.5.0
336
361
 
337
362
  ### Minor Changes
338
363
 
339
- - 520a97b: Add `ZoomOptions` prop in map package
364
+ - 520a97b: Add `ZoomOptions` prop in map package
340
365
 
341
366
  ## 0.4.0
342
367
 
343
368
  ### Minor Changes
344
369
 
345
- - a11bf72: Additional helpers for highlight and zoom
346
- - 9334e81: Update to OpenLayers 9
370
+ - a11bf72: Additional helpers for highlight and zoom
371
+ - 9334e81: Update to OpenLayers 9
347
372
 
348
373
  ### Patch Changes
349
374
 
350
- - 1a8ad89: Update package.json metadata
351
- - fc6bf82: introduce sourceOptions parameter to WMTS layer
352
- - a0d8882: hide help texts during map export
353
- - 6162979: Update versions of core packages
354
- - ac7fdd1: Update documentation
355
- - 13ea342: Remove duplicate viewPadding application.
356
- - Updated dependencies [1a8ad89]
357
- - @open-pioneer/react-utils@0.2.2
375
+ - 1a8ad89: Update package.json metadata
376
+ - fc6bf82: introduce sourceOptions parameter to WMTS layer
377
+ - a0d8882: hide help texts during map export
378
+ - 6162979: Update versions of core packages
379
+ - ac7fdd1: Update documentation
380
+ - 13ea342: Remove duplicate viewPadding application.
381
+ - Updated dependencies [1a8ad89]
382
+ - @open-pioneer/react-utils@0.2.2
358
383
 
359
384
  ## 0.3.1
360
385
 
361
386
  ### Patch Changes
362
387
 
363
- - 611ddb9: Export interface `BaseFeature` from Map API and use it correctly in base packages `selection` and `search`.
388
+ - 611ddb9: Export interface `BaseFeature` from Map API and use it correctly in base packages `selection` and `search`.
364
389
 
365
390
  ## 0.3.0
366
391
 
367
392
  ### Minor Changes
368
393
 
369
- - ee7c2d4: Update runtime version.
370
- - 0456500: Add interface `BaseFeature` to Map API.
394
+ - ee7c2d4: Update runtime version.
395
+ - 0456500: Add interface `BaseFeature` to Map API.
371
396
 
372
397
  ### Patch Changes
373
398
 
374
- - a582e5e: Add property `viewPadding` to `HighlightOptions`.
375
- - Updated dependencies [762e7b9]
376
- - @open-pioneer/react-utils@0.2.1
399
+ - a582e5e: Add property `viewPadding` to `HighlightOptions`.
400
+ - Updated dependencies [762e7b9]
401
+ - @open-pioneer/react-utils@0.2.1
377
402
 
378
403
  ## 0.2.0
379
404
 
380
405
  ### Minor Changes
381
406
 
382
- - 70349a8: Update to new core packages major versions
407
+ - 70349a8: Update to new core packages major versions
383
408
 
384
409
  ### Patch Changes
385
410
 
386
- - Updated dependencies [70349a8]
387
- - @open-pioneer/react-utils@0.2.0
411
+ - Updated dependencies [70349a8]
412
+ - @open-pioneer/react-utils@0.2.0
388
413
 
389
414
  ## 0.1.1
390
415
 
391
416
  ### Patch Changes
392
417
 
393
- - 08bffbc: MapModel API has got new methods for zooming/highlighting
394
- - a58546b: Use `HttpService` for default health checks made by the map model.
395
- - a58546b: Use `HttpService` when loading images in WMSLayer.
396
- - 0c4ce04: Add OGC API Tiles (vector tiles) support
418
+ - 08bffbc: MapModel API has got new methods for zooming/highlighting
419
+ - a58546b: Use `HttpService` for default health checks made by the map model.
420
+ - a58546b: Use `HttpService` when loading images in WMSLayer.
421
+ - 0c4ce04: Add OGC API Tiles (vector tiles) support
397
422
 
398
423
  ## 0.1.0
399
424
 
400
425
  ### Minor Changes
401
426
 
402
- - bb2f27a: Initial release.
427
+ - bb2f27a: Initial release.
403
428
 
404
429
  ### Patch Changes
405
430
 
406
- - Updated dependencies [182da1c]
407
- - @open-pioneer/react-utils@0.1.0
431
+ - Updated dependencies [182da1c]
432
+ - @open-pioneer/react-utils@0.1.0
@@ -1 +1 @@
1
- {"version":3,"file":"MapRegistryImpl.js","sources":["MapRegistryImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Service, ServiceOptions } from \"@open-pioneer/runtime\";\nimport OlMap from \"ol/Map\";\nimport { MapModelImpl } from \"./model/MapModelImpl\";\nimport { MapConfigProvider, MapModel, MapRegistry } from \"./api\";\nimport { createMapModel } from \"./model/createMapModel\";\nimport { HttpService } from \"@open-pioneer/http\";\n\nconst LOG = createLogger(\"map:MapRegistry\");\n\ninterface References {\n providers: MapConfigProvider[];\n httpService: HttpService;\n}\n\ntype ModelJobResult = { kind: \"model\"; model: MapModelImpl } | { kind: \"error\"; error: Error };\n\nexport class MapRegistryImpl implements Service, MapRegistry {\n #httpService: HttpService;\n\n #configProviders = new Map<string, MapConfigProvider>();\n #entries = new Map<string, ModelJobResult>();\n #modelCreationJobs = new Map<string, Promise<ModelJobResult>>();\n #modelsByOlMap = new WeakMap<OlMap, MapModel>();\n #destroyed = false;\n\n constructor({ references }: ServiceOptions<References>) {\n this.#httpService = references.httpService;\n\n const providers = references.providers;\n for (const provider of providers) {\n this.#configProviders.set(provider.mapId, provider);\n }\n }\n\n destroy(): void {\n if (this.#destroyed) {\n return;\n }\n\n LOG.info(`Destroy map registry and all maps`);\n this.#destroyed = true;\n this.#entries.forEach((model) => {\n model.kind === \"model\" && model.model.destroy();\n });\n this.#entries.clear();\n this.#modelCreationJobs.clear();\n }\n\n async getMapModel(mapId: string): Promise<MapModel | undefined> {\n if (this.#destroyed) {\n throw new Error(\"MapRegistry has already been destroyed.\");\n }\n\n const creationJob = this.#modelCreationJobs.get(mapId);\n if (creationJob) {\n return unbox(await creationJob);\n }\n\n const entry = this.#entries.get(mapId);\n if (entry) {\n return unbox(entry);\n }\n\n const provider = this.#configProviders.get(mapId);\n if (!provider) {\n LOG.debug(`Failed to find a config provider for map id '${mapId}'.`);\n return undefined;\n }\n\n const modelPromise = this.#createModel(mapId, provider).catch((cause) => {\n const error = new Error(`Failed to construct map '${mapId}'`, { cause });\n const entry: ModelJobResult = { kind: \"error\", error };\n this.#modelCreationJobs.delete(mapId);\n this.#entries.set(mapId, entry);\n return entry;\n });\n this.#modelCreationJobs.set(mapId, modelPromise);\n return unbox(await modelPromise);\n }\n\n async expectMapModel(mapId: string): Promise<MapModel> {\n const model = await this.getMapModel(mapId);\n if (!model) {\n throw new Error(`No configuration available for map with id '${mapId}'.`);\n }\n return model;\n }\n\n getMapModelByRawInstance(olMap: OlMap): MapModel | undefined {\n return this.#modelsByOlMap.get(olMap);\n }\n\n async #createModel(mapId: string, provider: MapConfigProvider): Promise<ModelJobResult> {\n LOG.info(`Creating map with id '${mapId}'`);\n const mapConfig = await provider.getMapConfig();\n const mapModel = await createMapModel(mapId, mapConfig, this.#httpService);\n\n if (this.#destroyed) {\n mapModel.destroy();\n throw new Error(`MapRegistry has been destroyed.`);\n }\n\n const entry: ModelJobResult = { kind: \"model\", model: mapModel };\n this.#entries.set(mapId, entry);\n this.#modelCreationJobs.delete(mapId);\n this.#modelsByOlMap.set(mapModel.olMap, mapModel);\n return entry;\n }\n}\n\nfunction unbox(entry: ModelJobResult): MapModelImpl {\n if (entry.kind === \"error\") {\n throw entry.error;\n }\n return entry.model;\n}\n"],"names":["entry"],"mappings":";;;AAUA,MAAM,GAAA,GAAM,aAAa,iBAAiB,CAAA,CAAA;AASnC,MAAM,eAAgD,CAAA;AAAA,EACzD,YAAA,CAAA;AAAA,EAEA,gBAAA,uBAAuB,GAA+B,EAAA,CAAA;AAAA,EACtD,QAAA,uBAAe,GAA4B,EAAA,CAAA;AAAA,EAC3C,kBAAA,uBAAyB,GAAqC,EAAA,CAAA;AAAA,EAC9D,cAAA,uBAAqB,OAAyB,EAAA,CAAA;AAAA,EAC9C,UAAa,GAAA,KAAA,CAAA;AAAA,EAEb,WAAA,CAAY,EAAE,UAAA,EAA0C,EAAA;AACpD,IAAA,IAAA,CAAK,eAAe,UAAW,CAAA,WAAA,CAAA;AAE/B,IAAA,MAAM,YAAY,UAAW,CAAA,SAAA,CAAA;AAC7B,IAAA,KAAA,MAAW,YAAY,SAAW,EAAA;AAC9B,MAAA,IAAA,CAAK,gBAAiB,CAAA,GAAA,CAAI,QAAS,CAAA,KAAA,EAAO,QAAQ,CAAA,CAAA;AAAA,KACtD;AAAA,GACJ;AAAA,EAEA,OAAgB,GAAA;AACZ,IAAA,IAAI,KAAK,UAAY,EAAA;AACjB,MAAA,OAAA;AAAA,KACJ;AAEA,IAAA,GAAA,CAAI,KAAK,CAAmC,iCAAA,CAAA,CAAA,CAAA;AAC5C,IAAA,IAAA,CAAK,UAAa,GAAA,IAAA,CAAA;AAClB,IAAK,IAAA,CAAA,QAAA,CAAS,OAAQ,CAAA,CAAC,KAAU,KAAA;AAC7B,MAAA,KAAA,CAAM,IAAS,KAAA,OAAA,IAAW,KAAM,CAAA,KAAA,CAAM,OAAQ,EA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EAAE,IAAM,EAAA,OAAA,EAAS,OAAO,QAAS,EAAA,CAAA;AAC/D,IAAK,IAAA,CAAA,QAAA,CAAS,GAAI,CAAA,KAAA,EAAO,KAAK,CAAA,CAAA;AAC9B,IAAK,IAAA,CAAA,kBAAA,CAAmB,OAAO,KAAK,CAAA,CAAA;AACpC,IAAA,IAAA,CAAK,cAAe,CAAA,GAAA,CAAI,QAAS,CAAA,KAAA,EAAO,QAAQ,CAAA,CAAA;AAChD,IAAO,OAAA,KAAA,CAAA;AAAA,GACX;AACJ,CAAA;AAEA,SAAS,MAAM,KAAqC,EAAA;AAChD,EAAI,IAAA,KAAA,CAAM,SAAS,OAAS,EAAA;AACxB,IAAA,MAAM,KAAM,CAAA,KAAA,CAAA;AAAA,GAChB;AACA,EAAA,OAAO,KAAM,CAAA,KAAA,CAAA;AACjB;;;;"}
1
+ {"version":3,"file":"MapRegistryImpl.js","sources":["MapRegistryImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { createLogger } from \"@open-pioneer/core\";\nimport { Service, ServiceOptions } from \"@open-pioneer/runtime\";\nimport OlMap from \"ol/Map\";\nimport { MapModelImpl } from \"./model/MapModelImpl\";\nimport { MapConfigProvider, MapModel, MapRegistry } from \"./api\";\nimport { createMapModel } from \"./model/createMapModel\";\nimport { HttpService } from \"@open-pioneer/http\";\n\nconst LOG = createLogger(\"map:MapRegistry\");\n\ninterface References {\n providers: MapConfigProvider[];\n httpService: HttpService;\n}\n\ntype ModelJobResult = { kind: \"model\"; model: MapModelImpl } | { kind: \"error\"; error: Error };\n\nexport class MapRegistryImpl implements Service, MapRegistry {\n #httpService: HttpService;\n\n #configProviders = new Map<string, MapConfigProvider>();\n #entries = new Map<string, ModelJobResult>();\n #modelCreationJobs = new Map<string, Promise<ModelJobResult>>();\n #modelsByOlMap = new WeakMap<OlMap, MapModel>();\n #destroyed = false;\n\n constructor({ references }: ServiceOptions<References>) {\n this.#httpService = references.httpService;\n\n const providers = references.providers;\n for (const provider of providers) {\n this.#configProviders.set(provider.mapId, provider);\n }\n }\n\n destroy(): void {\n if (this.#destroyed) {\n return;\n }\n\n LOG.info(`Destroy map registry and all maps`);\n this.#destroyed = true;\n this.#entries.forEach((model) => {\n model.kind === \"model\" && model.model.destroy();\n });\n this.#entries.clear();\n this.#modelCreationJobs.clear();\n }\n\n async getMapModel(mapId: string): Promise<MapModel | undefined> {\n if (this.#destroyed) {\n throw new Error(\"MapRegistry has already been destroyed.\");\n }\n\n const creationJob = this.#modelCreationJobs.get(mapId);\n if (creationJob) {\n return unbox(await creationJob);\n }\n\n const entry = this.#entries.get(mapId);\n if (entry) {\n return unbox(entry);\n }\n\n const provider = this.#configProviders.get(mapId);\n if (!provider) {\n LOG.debug(`Failed to find a config provider for map id '${mapId}'.`);\n return undefined;\n }\n\n const modelPromise = this.#createModel(mapId, provider).catch((cause) => {\n const error = new Error(`Failed to construct map '${mapId}'`, { cause });\n const entry: ModelJobResult = { kind: \"error\", error };\n this.#modelCreationJobs.delete(mapId);\n this.#entries.set(mapId, entry);\n return entry;\n });\n this.#modelCreationJobs.set(mapId, modelPromise);\n return unbox(await modelPromise);\n }\n\n async expectMapModel(mapId: string): Promise<MapModel> {\n const model = await this.getMapModel(mapId);\n if (!model) {\n throw new Error(`No configuration available for map with id '${mapId}'.`);\n }\n return model;\n }\n\n getMapModelByRawInstance(olMap: OlMap): MapModel | undefined {\n return this.#modelsByOlMap.get(olMap);\n }\n\n async #createModel(mapId: string, provider: MapConfigProvider): Promise<ModelJobResult> {\n LOG.info(`Creating map with id '${mapId}'`);\n const mapConfig = await provider.getMapConfig();\n const mapModel = await createMapModel(mapId, mapConfig, this.#httpService);\n\n if (this.#destroyed) {\n mapModel.destroy();\n throw new Error(`MapRegistry has been destroyed.`);\n }\n\n const entry: ModelJobResult = { kind: \"model\", model: mapModel };\n this.#entries.set(mapId, entry);\n this.#modelCreationJobs.delete(mapId);\n this.#modelsByOlMap.set(mapModel.olMap, mapModel);\n return entry;\n }\n}\n\nfunction unbox(entry: ModelJobResult): MapModelImpl {\n if (entry.kind === \"error\") {\n throw entry.error;\n }\n return entry.model;\n}\n"],"names":["entry"],"mappings":";;;AAUA,MAAM,GAAA,GAAM,aAAa,iBAAiB,CAAA;AASnC,MAAM,eAAgD,CAAA;AAAA,EACzD,YAAA;AAAA,EAEA,gBAAA,uBAAuB,GAA+B,EAAA;AAAA,EACtD,QAAA,uBAAe,GAA4B,EAAA;AAAA,EAC3C,kBAAA,uBAAyB,GAAqC,EAAA;AAAA,EAC9D,cAAA,uBAAqB,OAAyB,EAAA;AAAA,EAC9C,UAAa,GAAA,KAAA;AAAA,EAEb,WAAA,CAAY,EAAE,UAAA,EAA0C,EAAA;AACpD,IAAA,IAAA,CAAK,eAAe,UAAW,CAAA,WAAA;AAE/B,IAAA,MAAM,YAAY,UAAW,CAAA,SAAA;AAC7B,IAAA,KAAA,MAAW,YAAY,SAAW,EAAA;AAC9B,MAAA,IAAA,CAAK,gBAAiB,CAAA,GAAA,CAAI,QAAS,CAAA,KAAA,EAAO,QAAQ,CAAA;AAAA;AACtD;AACJ,EAEA,OAAgB,GAAA;AACZ,IAAA,IAAI,KAAK,UAAY,EAAA;AACjB,MAAA;AAAA;AAGJ,IAAA,GAAA,CAAI,KAAK,CAAmC,iCAAA,CAAA,CAAA;AAC5C,IAAA,IAAA,CAAK,UAAa,GAAA,IAAA;AAClB,IAAK,IAAA,CAAA,QAAA,CAAS,OAAQ,CAAA,CAAC,KAAU,KAAA;AAC7B,MAAA,KAAA,CAAM,IAAS,KAAA,OAAA,IAAW,KAAM,CAAA,KAAA,CAAM,OAAQ,EAAA;AAAA,KACjD,CAAA;AACD,IAAA,IAAA,CAAK,SAAS,KAAM,EAAA;AACpB,IAAA,IAAA,CAAK,mBAAmB,KAAM,EAAA;AAAA;AAClC,EAEA,MAAM,YAAY,KAA8C,EAAA;AAC5D,IAAA,IAA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,CAAA,KAAA;AAAA;AAEhB,EAAA,OAAO,KAAM,CAAA,KAAA;AACjB;;;;"}
package/README.md CHANGED
@@ -7,8 +7,8 @@ APIs provided by this package can be used to configure, embed and access the map
7
7
 
8
8
  To use the map in your app, follow these two steps:
9
9
 
10
- - Add a `MapContainer` component to your app (see [Map container component](#map-container-component)).
11
- - Implement a `MapConfigProvider` (see [Map configuration](#map-configuration)).
10
+ - Add a `MapContainer` component to your app (see [Map container component](#map-container-component)).
11
+ - Implement a `MapConfigProvider` (see [Map configuration](#map-configuration)).
12
12
 
13
13
  To access or manipulate the content of the map programmatically, see [Using the map model](#using-the-map-model).
14
14
 
@@ -55,10 +55,10 @@ by animating the view) and `preserve-extent` ´(ensures that the extent remains
55
55
 
56
56
  To pass custom React components onto the map, the following anchor-points are provided:
57
57
 
58
- - `top-left`
59
- - `top-right`
60
- - `bottom-left`
61
- - `bottom-right`
58
+ - `top-left`
59
+ - `top-right`
60
+ - `bottom-left`
61
+ - `bottom-right`
62
62
 
63
63
  Example: Integration of a map anchor component into the map container with position `bottom-right` and optional horizontal and vertical gap:
64
64
 
@@ -113,10 +113,10 @@ export default defineBuildConfig({
113
113
  The service itself needs to implement the `MapConfigProvider` interface.
114
114
  The following map options are supported:
115
115
 
116
- - `initialView`,
117
- - `projection`,
118
- - `layers` (see [Layer configuration](#layer-configuration)),
119
- - `advanced`
116
+ - `initialView`,
117
+ - `projection`,
118
+ - `layers` (see [Layer configuration](#layer-configuration)),
119
+ - `advanced`
120
120
 
121
121
  Always use the provided map model to access the map initially.
122
122
  Use `.olMap` only, when the raw instance is required.
@@ -273,8 +273,8 @@ An optional property `healthCheck` allows to determine the availability status o
273
273
 
274
274
  It is possible to provide
275
275
 
276
- - either a URL to perform a test request check the returned HTTP status
277
- - or a `HealthCheckFunction` performing a custom check and returning the state
276
+ - either a URL to perform a test request check the returned HTTP status
277
+ - or a `HealthCheckFunction` performing a custom check and returning the state
278
278
 
279
279
  **Important**: The availability of a layer is only checked once during initialization to reduce the load on server side. If a service becomes available again later, the application will need to be reloaded in order to update the availability status.
280
280
 
@@ -659,8 +659,8 @@ const childLayers = group.layers; // Access child layers
659
659
 
660
660
  > Limitations:
661
661
  >
662
- > - Do not add or remove layers directly to or from the underlying OpenLayers layer group (`group.olLayer`)! Changes are not synchronized with the `GroupLayer` instance.
663
- > - Currently, it is not possible to manipulate (add or remove) the child layers of a `GroupLayer` during runtime.
662
+ > - Do not add or remove layers directly to or from the underlying OpenLayers layer group (`group.olLayer`)! Changes are not synchronized with the `GroupLayer` instance.
663
+ > - Currently, it is not possible to manipulate (add or remove) the child layers of a `GroupLayer` during runtime.
664
664
 
665
665
  #### Register additional projections
666
666
 
@@ -698,20 +698,20 @@ This package allows interacting with maps and their layers through multiple inte
698
698
 
699
699
  The most important API items are as follows:
700
700
 
701
- - The `MapRegistry` service (inject via `"map.MapRegistry"`).
702
- This service is used to obtain a reference to the `MapModel` via `registry.getMapModel(mapId)`.
701
+ - The `MapRegistry` service (inject via `"map.MapRegistry"`).
702
+ This service is used to obtain a reference to the `MapModel` via `registry.getMapModel(mapId)`.
703
703
 
704
704
  > NOTE: From inside a React component you can also use the hook `useMapModel(mapId)`.
705
705
 
706
- - The `MapModel` represents a map in an application.
707
- Through the `MapModel` one can obtain the map's base layers, operational layers and so on.
708
- The `MapModel` also provides access to the raw OpenLayers `olMap` for advanced use cases.
706
+ - The `MapModel` represents a map in an application.
707
+ Through the `MapModel` one can obtain the map's base layers, operational layers and so on.
708
+ The `MapModel` also provides access to the raw OpenLayers `olMap` for advanced use cases.
709
709
 
710
710
  > NOTE: The `olMap` is manipulated by the `MapModel` to implement its functionality (for example, to add or remove layer instances). When using the `olMap` directly, treat it carefully and as a shared resource.
711
711
 
712
- - The `Layer` interface and its various implementations.
713
- This interface is used to make common properties and methods available (such as `.title`, or `.setVisible`).
714
- Layers may also have `.sublayers`, which support the same basic properties as other layer types.
712
+ - The `Layer` interface and its various implementations.
713
+ This interface is used to make common properties and methods available (such as `.title`, or `.setVisible`).
714
+ Layers may also have `.sublayers`, which support the same basic properties as other layer types.
715
715
 
716
716
  As is the case in `MapModel`, one can retrieve the raw OpenLayers `olLayer` from a layer instance (the same restrictions apply, see above).
717
717
 
@@ -721,16 +721,16 @@ For example, other application components may not react to raw property changes
721
721
 
722
722
  This point is especially important for the map model's central features:
723
723
 
724
- - Map composition (access and configuration of layers, base layers, removing layers)
725
- - Layer visibility
726
- - Custom layer metadata (`attributes`)
724
+ - Map composition (access and configuration of layers, base layers, removing layers)
725
+ - Layer visibility
726
+ - Custom layer metadata (`attributes`)
727
727
 
728
728
  In those cases, the properties or methods provided by this package should always be used:
729
729
 
730
- - `map.layers.addLayer(layer)` and `map.layers.removeLayerById(layerId)` to add or remove layers
731
- - `map.layers.getAllLayers()`, `map.layers.getBaseLayers()`, `map.layers.getOperationalLayers()` etc. to access (top-level) layers
732
- - `layer.setVisible(visible)` and `map.layers.activateBaseLayer(layerId)` to control visibility
733
- - `layer.updateAttributes()` and `layer.deleteAttributes()` to change a layer's custom attributes
730
+ - `map.layers.addLayer(layer)` and `map.layers.removeLayerById(layerId)` to add or remove layers
731
+ - `map.layers.getLayers()`, `map.layers.getBaseLayers()`, `map.layers.getOperationalLayers()` etc. to access (top-level) layers
732
+ - `layer.setVisible(visible)` and `map.layers.activateBaseLayer(layerId)` to control visibility
733
+ - `layer.updateAttributes()` and `layer.deleteAttributes()` to change a layer's custom attributes
734
734
 
735
735
  #### Layer classes
736
736
 
@@ -2,8 +2,12 @@ import { Geometry } from "ol/geom";
2
2
  import { Style } from "ol/style";
3
3
  /**
4
4
  * Base interface for all feature objects with geometry and / or attribute information.
5
+ *
6
+ * @typeParam PropertiesType The type of the properties of the feature.
7
+ * Use this parameter if you know the shape of features ahead of time.
8
+ * Note that this parameter should be some kind of object (not an array or primitive type).
5
9
  */
6
- export interface BaseFeature {
10
+ export interface BaseFeature<PropertiesType = Readonly<Record<string, unknown>>> {
7
11
  /**
8
12
  * Identifier for the feature object. Must be unique within all features of one source/layer.
9
13
  *
@@ -23,7 +27,7 @@ export interface BaseFeature {
23
27
  /**
24
28
  * Properties of the feature.
25
29
  */
26
- properties?: Readonly<Record<string, unknown>>;
30
+ properties?: PropertiesType;
27
31
  /**
28
32
  * Additional style information for displaying the feature on the map.
29
33
  */
package/api/index.d.ts CHANGED
@@ -5,7 +5,6 @@ export * from "./MapRegistry";
5
5
  export * from "./layers";
6
6
  export * from "./shared";
7
7
  export { getProjection, registerProjections, type ProjectionDefinition } from "../projections";
8
- export { BkgTopPlusOpen, type BkgTopPlusOpenProps } from "../layers/BkgTopPlusOpen";
9
8
  export { useView, useProjection, useResolution, useCenter, useScale } from "../ui/hooks";
10
9
  export { MapAnchor, type MapAnchorProps, type MapAnchorPosition } from "../ui/MapAnchor";
11
10
  export { MapContainer, type MapContainerProps } from "../ui/MapContainer";
@@ -1 +1 @@
1
- {"version":3,"file":"GroupLayer.js","sources":["GroupLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Group } from \"ol/layer\";\nimport { GroupLayerImpl } from \"../../model/layers/GroupLayerImpl\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { AnyLayer, ChildrenCollection, Layer, LayerBaseType, LayerConfig } from \"./base\";\n\n/**\n * Configuration options to construct a {@link GroupLayer}.\n */\nexport interface GroupLayerConfig extends LayerConfig {\n /**\n * List of layers that belong to the new group layer.\n *\n * The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed.\n * A layer must have a unique parent: it can only be added to the map or a single group layer.\n */\n layers: Layer[];\n}\n\n/**\n * Represents a group of layers.\n *\n * A group layer contains a collection of {@link Layer} children.\n * Groups can be nested to form a hierarchy.\n */\nexport interface GroupLayer extends LayerBaseType {\n readonly type: \"group\";\n\n /**\n * Layers contained in this group.\n */\n readonly layers: GroupLayerCollection;\n\n /**\n * Raw OpenLayers group instance.\n *\n * **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized!\n */\n readonly olLayer: Group;\n\n readonly sublayers: undefined;\n}\n\n/**\n * Contains {@link Layer} instances that belong to a {@link GroupLayer}\n */\nexport interface GroupLayerCollection extends ChildrenCollection<Layer> {\n /**\n * Returns all layers in this collection\n */\n getLayers(options?: LayerRetrievalOptions): Layer[];\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 group contains many, deeply nested sub groups, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): AnyLayer[];\n}\n\nexport interface GroupLayerConstructor {\n prototype: GroupLayer;\n\n /** Creates a new {@link GroupLayer}. */\n new (config: GroupLayerConfig): GroupLayer;\n}\n\nexport const GroupLayer: GroupLayerConstructor = GroupLayerImpl;\n"],"names":[],"mappings":";;AAuEO,MAAM,UAAoC,GAAA;;;;"}
1
+ {"version":3,"file":"GroupLayer.js","sources":["GroupLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type { Group } from \"ol/layer\";\nimport { GroupLayerImpl } from \"../../model/layers/GroupLayerImpl\";\nimport type { LayerRetrievalOptions, RecursiveRetrievalOptions } from \"../shared\";\nimport type { AnyLayer, ChildrenCollection, Layer, LayerBaseType, LayerConfig } from \"./base\";\n\n/**\n * Configuration options to construct a {@link GroupLayer}.\n */\nexport interface GroupLayerConfig extends LayerConfig {\n /**\n * List of layers that belong to the new group layer.\n *\n * The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed.\n * A layer must have a unique parent: it can only be added to the map or a single group layer.\n */\n layers: Layer[];\n}\n\n/**\n * Represents a group of layers.\n *\n * A group layer contains a collection of {@link Layer} children.\n * Groups can be nested to form a hierarchy.\n */\nexport interface GroupLayer extends LayerBaseType {\n readonly type: \"group\";\n\n /**\n * Layers contained in this group.\n */\n readonly layers: GroupLayerCollection;\n\n /**\n * Raw OpenLayers group instance.\n *\n * **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized!\n */\n readonly olLayer: Group;\n\n readonly sublayers: undefined;\n}\n\n/**\n * Contains {@link Layer} instances that belong to a {@link GroupLayer}\n */\nexport interface GroupLayerCollection extends ChildrenCollection<Layer> {\n /**\n * Returns all layers in this collection\n */\n getLayers(options?: LayerRetrievalOptions): Layer[];\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 group contains many, deeply nested sub groups, this function could potentially be expensive.\n */\n getRecursiveLayers(options?: RecursiveRetrievalOptions): AnyLayer[];\n}\n\nexport interface GroupLayerConstructor {\n prototype: GroupLayer;\n\n /** Creates a new {@link GroupLayer}. */\n new (config: GroupLayerConfig): GroupLayer;\n}\n\nexport const GroupLayer: GroupLayerConstructor = GroupLayerImpl;\n"],"names":[],"mappings":";;AAuEO,MAAM,UAAoC,GAAA;;;;"}
@@ -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, 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 readonly layers: undefined;\n}\n\nexport const SimpleLayer: SimpleLayerConstructor = SimpleLayerImpl;\n"],"names":[],"mappings":";;AAmCO,MAAM,WAAsC,GAAA;;;;"}
1
+ {"version":3,"file":"SimpleLayer.js","sources":["SimpleLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 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 readonly layers: undefined;\n}\n\nexport const SimpleLayer: SimpleLayerConstructor = SimpleLayerImpl;\n"],"names":[],"mappings":";;AAmCO,MAAM,WAAsC,GAAA;;;;"}
@@ -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 {\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 * Whether to automatically fetch capabilities from the service when needed (default: `true`).\n *\n * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.\n * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.\n */\n fetchCapabilities?: boolean;\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 readonly layers: undefined;\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":";;AAqFO,MAAM,QAAgC,GAAA;;;;"}
1
+ {"version":3,"file":"WMSLayer.js","sources":["WMSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 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 * Whether to automatically fetch capabilities from the service when needed (default: `true`).\n *\n * Setting this to `false` can be useful as a performance optimization when capabilities are not really required by the application.\n * Note that this will disable some features of the WMS layer: for example, the legend URL will not be available.\n */\n fetchCapabilities?: boolean;\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 readonly layers: undefined;\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":";;AAqFO,MAAM,QAAgC,GAAA;;;;"}
@@ -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 { LayerBaseType, LayerConfig } from \"./base\";\nimport { WMTSLayerImpl } from \"../../model/layers/WMTSLayerImpl\";\n\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}\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\n readonly layers: undefined;\n}\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":";;AA+CO,MAAM,SAAkC,GAAA;;;;"}
1
+ {"version":3,"file":"WMTSLayer.js","sources":["WMTSLayer.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 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\";\n\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}\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\n readonly layers: undefined;\n}\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":";;AA+CO,MAAM,SAAkC,GAAA;;;;"}