@open-pioneer/map 0.6.1 → 0.8.0-dev.20241120115147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +214 -0
- package/README.md +127 -12
- package/api/MapModel.d.ts +50 -17
- package/api/index.d.ts +2 -1
- package/api/layers/GroupLayer.d.ts +50 -0
- package/api/layers/GroupLayer.js +6 -0
- package/api/layers/GroupLayer.js.map +1 -0
- package/api/layers/SimpleLayer.d.ts +5 -2
- package/api/layers/SimpleLayer.js.map +1 -1
- package/api/layers/WMSLayer.d.ts +6 -3
- package/api/layers/WMSLayer.js.map +1 -1
- package/api/layers/WMTSLayer.d.ts +4 -2
- package/api/layers/WMTSLayer.js.map +1 -1
- package/api/layers/base.d.ts +77 -18
- package/api/layers/base.js +9 -0
- package/api/layers/base.js.map +1 -0
- package/api/layers/index.d.ts +1 -0
- package/index.js +3 -0
- package/index.js.map +1 -1
- package/model/AbstractLayer.d.ts +4 -3
- package/model/AbstractLayer.js +16 -23
- package/model/AbstractLayer.js.map +1 -1
- package/model/AbstractLayerBase.d.ts +21 -5
- package/model/AbstractLayerBase.js +48 -35
- package/model/AbstractLayerBase.js.map +1 -1
- package/model/Highlights.d.ts +11 -4
- package/model/Highlights.js +5 -1
- package/model/Highlights.js.map +1 -1
- package/model/LayerCollectionImpl.d.ts +10 -10
- package/model/LayerCollectionImpl.js +39 -37
- package/model/LayerCollectionImpl.js.map +1 -1
- package/model/MapModelImpl.d.ts +16 -3
- package/model/MapModelImpl.js +94 -25
- package/model/MapModelImpl.js.map +1 -1
- package/model/SublayersCollectionImpl.d.ts +6 -3
- package/model/SublayersCollectionImpl.js +6 -4
- package/model/SublayersCollectionImpl.js.map +1 -1
- package/model/layers/GroupLayerImpl.d.ts +39 -0
- package/model/layers/GroupLayerImpl.js +88 -0
- package/model/layers/GroupLayerImpl.js.map +1 -0
- package/model/layers/SimpleLayerImpl.d.ts +4 -1
- package/model/layers/SimpleLayerImpl.js +6 -0
- package/model/layers/SimpleLayerImpl.js.map +1 -1
- package/model/layers/WMSLayerImpl.d.ts +11 -7
- package/model/layers/WMSLayerImpl.js +64 -51
- package/model/layers/WMSLayerImpl.js.map +1 -1
- package/model/layers/WMTSLayerImpl.d.ts +4 -5
- package/model/layers/WMTSLayerImpl.js +16 -13
- package/model/layers/WMTSLayerImpl.js.map +1 -1
- package/package.json +11 -12
- package/ui/CssProps.d.ts +9 -0
- package/ui/CssProps.js +13 -0
- package/ui/CssProps.js.map +1 -0
- package/ui/DefaultMapProvider.d.ts +39 -0
- package/ui/DefaultMapProvider.js +24 -0
- package/ui/DefaultMapProvider.js.map +1 -0
- package/ui/MapAnchor.d.ts +0 -3
- package/ui/MapAnchor.js +5 -49
- package/ui/MapAnchor.js.map +1 -1
- package/ui/MapContainer.d.ts +3 -3
- package/ui/MapContainer.js +30 -25
- package/ui/MapContainer.js.map +1 -1
- package/ui/MapContainerContext.d.ts +7 -0
- package/ui/MapContainerContext.js +17 -0
- package/ui/MapContainerContext.js.map +1 -0
- package/ui/computeMapAnchorStyles.d.ts +3 -0
- package/ui/computeMapAnchorStyles.js +51 -0
- package/ui/computeMapAnchorStyles.js.map +1 -0
- package/ui/hooks.d.ts +10 -0
- package/ui/hooks.js.map +1 -1
- package/ui/styles.css +7 -0
- package/ui/styles.css.map +1 -1
- package/ui/useMapModel.d.ts +33 -6
- package/ui/useMapModel.js +40 -2
- package/ui/useMapModel.js.map +1 -1
- package/ui/MapContext.d.ts +0 -11
- package/ui/MapContext.js +0 -17
- package/ui/MapContext.js.map +0 -1
- package/util/defer.d.ts +0 -18
- package/util/defer.js +0 -21
- package/util/defer.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,219 @@
|
|
|
1
1
|
# @open-pioneer/map
|
|
2
2
|
|
|
3
|
+
## 0.8.0-dev.20241120115147
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b717121: Update from OL 9 to OL 10.
|
|
8
|
+
- e7978a8: - **Breaking:** Remove most events from the map model and the layer interfaces.
|
|
9
|
+
All events that were merely used to synchronized state (e.g. `changed:title` etc.) have been removed.
|
|
10
|
+
|
|
11
|
+
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).
|
|
12
|
+
This change greatly simplifies the code that is necessary to access up-to-date values and to react to changes.
|
|
13
|
+
|
|
14
|
+
For example, from inside a React component, you can now write:
|
|
15
|
+
|
|
16
|
+
```jsx
|
|
17
|
+
import { useReactiveSnapshot } from "@open-pioneer/reactivity";
|
|
18
|
+
|
|
19
|
+
function YourComponent() {
|
|
20
|
+
// Always up to date, even if the layer's title changes.
|
|
21
|
+
// No more need to listen to events.
|
|
22
|
+
const title = useReactiveSnapshot(() => layer.title, [layer]);
|
|
23
|
+
return <div>{title}</div>;
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
And inside a normal JavaScript function, you can watch for changes like this:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { watch } from "@conterra/reactivity-core";
|
|
31
|
+
|
|
32
|
+
const watchHandle = watch(
|
|
33
|
+
() => [layer.title],
|
|
34
|
+
([newTitle]) => {
|
|
35
|
+
console.log("The title changed to", newTitle);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
// Later, cleanup:
|
|
40
|
+
watchHandle.destroy();
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
For more details, check the [Reactivity API documentation](https://github.com/conterra/reactivity/blob/main/packages/reactivity-core/README.md).
|
|
44
|
+
|
|
45
|
+
- 7ae9f90: Add new `children` property to all layers.
|
|
46
|
+
This property makes it possible to handle any layer children in a generic fashion, regardless of the layer's actual type.
|
|
47
|
+
|
|
48
|
+
`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.
|
|
49
|
+
|
|
50
|
+
- d8337a6: The following hooks are deprecated and will be removed in a future release:
|
|
51
|
+
|
|
52
|
+
- `useView`
|
|
53
|
+
- `useProjection`
|
|
54
|
+
- `useResolution`
|
|
55
|
+
- `useCenter`
|
|
56
|
+
- `useScale`
|
|
57
|
+
|
|
58
|
+
They can all be replaced by using the new reactive properties on the `MapModel`, for example:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
// old:
|
|
62
|
+
const center = useCenter(olMap);
|
|
63
|
+
|
|
64
|
+
// new:
|
|
65
|
+
const center = useReactiveSnapshot(() => mapModel.center, [mapModel]);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- 2fa8020: Update trails core package dependencies.
|
|
69
|
+
|
|
70
|
+
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
71
|
+
- Removes any obsolete references to `@chakra-ui/system`.
|
|
72
|
+
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
73
|
+
|
|
74
|
+
- 7ae9f90: Add new layer type `GroupLayer` to to the Map API.
|
|
75
|
+
|
|
76
|
+
A `GroupLayer` contains a list of `Layer` (e.g. `SimpleLayer` or `WMSLayer`). Because `GroupLayer` is a `Layer` as well nested groups are supported.
|
|
77
|
+
The child layers of a `GroupLayer` can be accessed with the `layers` property - `layers` is `undefined` if it is not a group.
|
|
78
|
+
The parent `GroupLayer` of a child layer can be accessed with the `parent` property - `parent` is `undefined` if this layer is not part of a group (or not a sublayer).
|
|
79
|
+
|
|
80
|
+
```js
|
|
81
|
+
const olLayer1 = new TileLayer({
|
|
82
|
+
source: new OSM()
|
|
83
|
+
});
|
|
84
|
+
const olLayer2 = new TileLayer({
|
|
85
|
+
source: new BkgTopPlusOpen()
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Create group layer with nested sub group
|
|
89
|
+
const group = new GroupLayer({
|
|
90
|
+
id: "group",
|
|
91
|
+
title: "a group layer",
|
|
92
|
+
layers: [
|
|
93
|
+
new SimpleLayer({
|
|
94
|
+
id: "member",
|
|
95
|
+
title: "group member",
|
|
96
|
+
olLayer: olLayer1
|
|
97
|
+
}),
|
|
98
|
+
new GroupLayer({
|
|
99
|
+
id: "subgroup",
|
|
100
|
+
title: "a nested group layer",
|
|
101
|
+
layers: [
|
|
102
|
+
new SimpleLayer({
|
|
103
|
+
id: "submember",
|
|
104
|
+
title: "subgroup member",
|
|
105
|
+
olLayer: olLayer2
|
|
106
|
+
})
|
|
107
|
+
]
|
|
108
|
+
})
|
|
109
|
+
]
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
const childLayers: GroupLayerCollection = group.layers; // Access child layers
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Layers can only be added to a single group or map.
|
|
116
|
+
Sublayers (e.g. `WMSSublayer`) cannot be added to a group directly.
|
|
117
|
+
|
|
118
|
+
- d8337a6: Provide new reactive properties on the `MapModel` type.
|
|
119
|
+
|
|
120
|
+
- `olView` (-> `olMap.getView()`)
|
|
121
|
+
- `projection` (-> `olMap.getView().getProjection()`)
|
|
122
|
+
- `resolution` (-> `olMap.getView().getResolution()`)
|
|
123
|
+
- `zoomLevel` (-> `olMap.getView().getZoom()`)
|
|
124
|
+
- `center` (-> `olMap.getView().getCenter()`)
|
|
125
|
+
- `scale` (derived from center and resolution)
|
|
126
|
+
|
|
127
|
+
Most of the listed properties are already available on raw OpenLayers objects (see code in parentheses above).
|
|
128
|
+
However, those OpenLayers properties require manual work for synchronization, whereas the new properties are reactive (and can be watched, for example, using `useReactiveSnapshot()`).
|
|
129
|
+
|
|
130
|
+
A new method `setScale()` has also been added to the model.
|
|
131
|
+
|
|
132
|
+
### Patch Changes
|
|
133
|
+
|
|
134
|
+
- b2127df: Improve documentation of layers in README
|
|
135
|
+
|
|
136
|
+
## 0.7.0
|
|
137
|
+
|
|
138
|
+
### Minor Changes
|
|
139
|
+
|
|
140
|
+
- 2502050: Introduce union types and `type` attributes for layers. This allows TypeScript narrowing for layers and determining a layer's type.
|
|
141
|
+
|
|
142
|
+
The `Layer` and `Sublayer` types for layers remain, but are unions of the corresponding concrete layer types now.
|
|
143
|
+
The layer type `LayerBase` has been removed and is replaced by `AnyLayerType`
|
|
144
|
+
to clarify that this type represents a union of all types of layer (currently `Layer` and `Sublayer`).
|
|
145
|
+
|
|
146
|
+
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).
|
|
147
|
+
|
|
148
|
+
The following `type` attribute values have been implemented at the layers:
|
|
149
|
+
|
|
150
|
+
- SimpleLayer: `simple`
|
|
151
|
+
- WMSLayer: `wms`
|
|
152
|
+
- WMSSubLayer: `wms-sublayer`
|
|
153
|
+
- WMTSLayer: `wmts`
|
|
154
|
+
|
|
155
|
+
Example of usage:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
import { AnyLayer, WMTSLayer, isSublayer } from "@open-pioneer/map";
|
|
159
|
+
|
|
160
|
+
export class ExampleClass {
|
|
161
|
+
//...
|
|
162
|
+
|
|
163
|
+
exampleFunction(layer: AnyLayer) {
|
|
164
|
+
// prop may be a layer of any type
|
|
165
|
+
|
|
166
|
+
// use layers type attribute to check layer type
|
|
167
|
+
if (layer.type === "wmts") {
|
|
168
|
+
layer.matrixSet; // prop only available on WMTSLayer
|
|
169
|
+
|
|
170
|
+
const wmtsLayer: WMTSLayer = layer; // type of layer is now narrowed to `WMTSLayer`
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// use new type guard to check if layer is a Sublayer
|
|
174
|
+
if (isSublayer(layer)) {
|
|
175
|
+
// type of layer is now narrowed to `WMSSublayer` (as it is currently the only type of Sublayer existing)
|
|
176
|
+
layer.parentLayer; // prop only available on Sublayers
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
- 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
|
|
183
|
+
|
|
184
|
+
### Patch Changes
|
|
185
|
+
|
|
186
|
+
- 310800c: Update core packages version.
|
|
187
|
+
- 583f1d6: The `mapId` or `map` properties are now optional on individual components.
|
|
188
|
+
You can use the `DefaultMapProvider` to configure an implicit default value.
|
|
189
|
+
|
|
190
|
+
Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
|
|
191
|
+
|
|
192
|
+
- 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
|
|
193
|
+
- 397d617: Reimplement computation of map anchor positioning using new css props.
|
|
194
|
+
- a8b3449: Switch to a new versioning strategy.
|
|
195
|
+
From now on, packages released by this repository share a common version number.
|
|
196
|
+
- 900eb11: Update dependencies.
|
|
197
|
+
- 583f1d6: The new component `DefaultMapProvider` allows you to configure the _default map_ for its children.
|
|
198
|
+
If `DefaultMapProvider` is used, you can omit the explicit `mapId` (or `map`) property on the individual UI components.
|
|
199
|
+
|
|
200
|
+
For many applications, `DefaultMapProvider` can be used to surround all (or most of) the application's UI.
|
|
201
|
+
|
|
202
|
+
Example:
|
|
203
|
+
|
|
204
|
+
```tsx
|
|
205
|
+
import { DefaultMapProvider } from "@open-pioneer/map";
|
|
206
|
+
|
|
207
|
+
<DefaultMapProvider mapId={MAP_ID}>
|
|
208
|
+
{/* no need to repeat the map id in this subtree, unless you want to use a different one */}
|
|
209
|
+
<MapContainer />
|
|
210
|
+
<Toc />
|
|
211
|
+
<ComplexChild />
|
|
212
|
+
</DefaultMapProvider>;
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
- 397d617: Move attribution of OL map according to the map view's padding.
|
|
216
|
+
|
|
3
217
|
## 0.6.1
|
|
4
218
|
|
|
5
219
|
### Patch Changes
|
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](#
|
|
11
|
-
- Implement a `MapConfigProvider` (see [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
|
|
|
@@ -36,10 +36,21 @@ function AppUI() {
|
|
|
36
36
|
}
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
> NOTE: There must be a `map.MapConfigProvider` that knows how to construct the map with the given ID (see [Map configuration](#
|
|
39
|
+
> NOTE: There must be a `map.MapConfigProvider` that knows how to construct the map with the given ID (see [Map configuration](#map-configuration)).
|
|
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:
|
|
@@ -190,7 +201,7 @@ export class MapConfigProviderImpl implements MapConfigProvider {
|
|
|
190
201
|
|
|
191
202
|
#### Layer configuration
|
|
192
203
|
|
|
193
|
-
Configure your custom layer inside the [Map configuration](#
|
|
204
|
+
Configure your custom layer inside the [Map configuration](#map-configuration) by using one of the layer classes provided by this package.
|
|
194
205
|
For example, `SimpleLayer` can be used to configure an arbitrary [`OpenLayers Layer`](https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html) as `olLayer` property.
|
|
195
206
|
|
|
196
207
|
> **Layer Order**
|
|
@@ -610,6 +621,47 @@ export class MapConfigProviderImpl implements MapConfigProvider {
|
|
|
610
621
|
}
|
|
611
622
|
```
|
|
612
623
|
|
|
624
|
+
##### GroupLayer
|
|
625
|
+
|
|
626
|
+
A `GroupLayer` contains a list of layers (e.g. `SimpleLayer`, `WMSLayer` or nested `GroupLayer`).
|
|
627
|
+
The visibility of all layers within the group is controlled via the parent group layer(s).
|
|
628
|
+
The hierarchy of the layers, which results from the (nested) groups, is rendered accordingly in the table of contents.
|
|
629
|
+
|
|
630
|
+
Example: Create (nested) group layers
|
|
631
|
+
|
|
632
|
+
```ts
|
|
633
|
+
// Create group layer with a nested sub group
|
|
634
|
+
const group = new GroupLayer({
|
|
635
|
+
id: "group",
|
|
636
|
+
title: "a group layer",
|
|
637
|
+
layers: [
|
|
638
|
+
new SimpleLayer({
|
|
639
|
+
id: "member",
|
|
640
|
+
title: "group member",
|
|
641
|
+
olLayer: olLayer1
|
|
642
|
+
}),
|
|
643
|
+
new GroupLayer({
|
|
644
|
+
id: "subgroup",
|
|
645
|
+
title: "a nested group layer",
|
|
646
|
+
layers: [
|
|
647
|
+
new SimpleLayer({
|
|
648
|
+
id: "submember",
|
|
649
|
+
title: "subgroup member",
|
|
650
|
+
olLayer: olLayer2
|
|
651
|
+
})
|
|
652
|
+
]
|
|
653
|
+
})
|
|
654
|
+
]
|
|
655
|
+
});
|
|
656
|
+
|
|
657
|
+
const childLayers = group.layers; // Access child layers
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
> Limitations:
|
|
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.
|
|
664
|
+
|
|
613
665
|
#### Register additional projections
|
|
614
666
|
|
|
615
667
|
The map supports only the following projections by default: `EPSG:4326`, `EPSG:3857`, `EPSG:25832` and `EPSG:25833`.
|
|
@@ -682,17 +734,80 @@ In those cases, the properties or methods provided by this package should always
|
|
|
682
734
|
|
|
683
735
|
#### Layer classes
|
|
684
736
|
|
|
685
|
-
This package currently
|
|
737
|
+
This package currently provides five layer implementations: `SimpleLayer`, `WMSLayer`, `WMTSLayer`, `GroupLayer` and `WMSSublayer`.
|
|
686
738
|
|
|
687
|
-
|
|
688
|
-
Instances of this class can be used to integrate arbitrary OpenLayers `Layer` instances into the map by configuring the `olLayer` constructor option.
|
|
689
|
-
Note that one can only achieve basic integration through this method: more advanced features such as automatic legends or sublayers will not be available.
|
|
739
|
+
The following diagram shows the inheritance structure of the corresponding layer types. The diagram is only intended to show the hierarchy of the layer types; for details on the properties and methods of the layer types, refer to the respective API documentation.
|
|
690
740
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
741
|
+
```mermaid
|
|
742
|
+
---
|
|
743
|
+
config:
|
|
744
|
+
class:
|
|
745
|
+
hideEmptyMembersBox: true
|
|
746
|
+
---
|
|
747
|
+
classDiagram
|
|
748
|
+
class AnyLayerBaseType {
|
|
749
|
+
type: string
|
|
750
|
+
}
|
|
751
|
+
<<abstract>> AnyLayerBaseType
|
|
694
752
|
|
|
695
|
-
|
|
753
|
+
class LayerBaseType {
|
|
754
|
+
type: string
|
|
755
|
+
}
|
|
756
|
+
<<abstract>> LayerBaseType
|
|
757
|
+
|
|
758
|
+
class SimpleLayer {
|
|
759
|
+
type: "simple"
|
|
760
|
+
constructor(config: SimpleLayerConfig)
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
class WMSLayer {
|
|
764
|
+
type: "wms"
|
|
765
|
+
constructor(config: WMSLayerConfig)
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
class WMTSLayer {
|
|
769
|
+
type: "wmts"
|
|
770
|
+
constructor(config: WMTSLayerConfig)
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
class GroupLayer {
|
|
774
|
+
type: "group"
|
|
775
|
+
constructor(config: GroupLayerConfig)
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
class Layer
|
|
779
|
+
<<union>> Layer
|
|
780
|
+
|
|
781
|
+
class Sublayer
|
|
782
|
+
<<union>> Sublayer
|
|
783
|
+
|
|
784
|
+
class SublayerBaseType {
|
|
785
|
+
type: string
|
|
786
|
+
}
|
|
787
|
+
<<abstract>> SublayerBaseType
|
|
788
|
+
|
|
789
|
+
class WMSSublayer {
|
|
790
|
+
type: "wms-sublayer"
|
|
791
|
+
constructor(config: WMSSublayerConfig)
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
AnyLayerBaseType <|-- LayerBaseType
|
|
795
|
+
AnyLayerBaseType <|-- SublayerBaseType
|
|
796
|
+
|
|
797
|
+
LayerBaseType <|-- SimpleLayer
|
|
798
|
+
LayerBaseType <|-- WMSLayer
|
|
799
|
+
LayerBaseType <|-- WMTSLayer
|
|
800
|
+
LayerBaseType <|-- GroupLayer
|
|
801
|
+
|
|
802
|
+
SublayerBaseType <|-- WMSSublayer
|
|
803
|
+
|
|
804
|
+
SimpleLayer .. Layer
|
|
805
|
+
WMSLayer .. Layer
|
|
806
|
+
WMTSLayer .. Layer
|
|
807
|
+
GroupLayer .. Layer
|
|
808
|
+
|
|
809
|
+
WMSSublayer .. Sublayer
|
|
810
|
+
```
|
|
696
811
|
|
|
697
812
|
#### Using the map model and layers in services
|
|
698
813
|
|
package/api/MapModel.d.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import type { EventSource, Resource } from "@open-pioneer/core";
|
|
2
2
|
import type OlMap from "ol/Map";
|
|
3
|
+
import type OlView from "ol/View";
|
|
3
4
|
import type OlBaseLayer from "ol/layer/Base";
|
|
4
5
|
import type { ExtentConfig } from "./MapConfig";
|
|
5
|
-
import type {
|
|
6
|
+
import type { AnyLayer, Layer } from "./layers";
|
|
6
7
|
import type { LayerRetrievalOptions } from "./shared";
|
|
7
8
|
import type { Geometry } from "ol/geom";
|
|
8
|
-
import { BaseFeature } from "./BaseFeature";
|
|
9
|
-
import { StyleLike } from "ol/style/Style";
|
|
9
|
+
import type { BaseFeature } from "./BaseFeature";
|
|
10
|
+
import type { StyleLike } from "ol/style/Style";
|
|
11
|
+
import type { Projection } from "ol/proj";
|
|
12
|
+
import type { Coordinate } from "ol/coordinate";
|
|
10
13
|
/** Events emitted by the {@link MapModel}. */
|
|
11
14
|
export interface MapModelEvents {
|
|
12
|
-
"changed": void;
|
|
13
|
-
"changed:container": void;
|
|
14
|
-
"changed:initialExtent": void;
|
|
15
15
|
"destroy": void;
|
|
16
16
|
}
|
|
17
17
|
/** Styleoptions supported when creating a new {@link Highlight}. */
|
|
@@ -70,7 +70,7 @@ export interface Highlight extends Resource {
|
|
|
70
70
|
readonly isActive: boolean;
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* Represents
|
|
73
|
+
* Represents an object in the map.
|
|
74
74
|
*/
|
|
75
75
|
export type DisplayTarget = BaseFeature | Geometry;
|
|
76
76
|
/**
|
|
@@ -83,11 +83,10 @@ export interface MapModel extends EventSource<MapModelEvents> {
|
|
|
83
83
|
readonly id: string;
|
|
84
84
|
/**
|
|
85
85
|
* The container in which the map is currently being rendered.
|
|
86
|
+
* This is the same as the target element of the underlying OpenLayers map.
|
|
86
87
|
*
|
|
87
88
|
* May be undefined if the map is not being rendered at the moment.
|
|
88
89
|
* May change at runtime.
|
|
89
|
-
*
|
|
90
|
-
* The `changed:container` event is emitted when this value changes.
|
|
91
90
|
*/
|
|
92
91
|
readonly container: HTMLElement | undefined;
|
|
93
92
|
/**
|
|
@@ -95,8 +94,6 @@ export interface MapModel extends EventSource<MapModelEvents> {
|
|
|
95
94
|
*
|
|
96
95
|
* May be undefined before the map is shown.
|
|
97
96
|
* This is guaranteed to be initialized if the promise returned by {@link whenDisplayed} has resolved.
|
|
98
|
-
*
|
|
99
|
-
* The `changed:initialExtent` event is emitted when this value changes.
|
|
100
97
|
*/
|
|
101
98
|
readonly initialExtent: ExtentConfig | undefined;
|
|
102
99
|
/**
|
|
@@ -110,6 +107,46 @@ export interface MapModel extends EventSource<MapModelEvents> {
|
|
|
110
107
|
* The raw OpenLayers map.
|
|
111
108
|
*/
|
|
112
109
|
readonly olMap: OlMap;
|
|
110
|
+
/**
|
|
111
|
+
* Returns the current view of the OpenLayers map.
|
|
112
|
+
*/
|
|
113
|
+
readonly olView: OlView;
|
|
114
|
+
/**
|
|
115
|
+
* Returns the current zoom level of the map.
|
|
116
|
+
* Same as `olView.getZoom()`, but reactive.
|
|
117
|
+
*/
|
|
118
|
+
readonly zoomLevel: number | undefined;
|
|
119
|
+
/**
|
|
120
|
+
* Returns the current resolution of the map.
|
|
121
|
+
* Same as `olView.getResolution()`, but reactive.
|
|
122
|
+
*/
|
|
123
|
+
readonly resolution: number | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the current center of the map.
|
|
126
|
+
* Same as `olView.getCenter()`, but reactive.
|
|
127
|
+
*/
|
|
128
|
+
readonly center: Coordinate | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Returns the current projection of the map (reactive).
|
|
131
|
+
*/
|
|
132
|
+
readonly projection: Projection;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the current scale of the map.
|
|
135
|
+
*
|
|
136
|
+
* Technically, this is the _denominator_ of the current scale.
|
|
137
|
+
* In order to display it, use a format like `1:${scale}`.
|
|
138
|
+
*/
|
|
139
|
+
readonly scale: number | undefined;
|
|
140
|
+
/**
|
|
141
|
+
* Changes the current scale of the map to the given value.
|
|
142
|
+
*
|
|
143
|
+
* Internally, this computes a new zoom level / resolution based on the scale
|
|
144
|
+
* and the current center.
|
|
145
|
+
* The new resolution is then applied to the current `olView`.
|
|
146
|
+
*
|
|
147
|
+
* See also {@link scale}.
|
|
148
|
+
*/
|
|
149
|
+
setScale(newScale: number): void;
|
|
113
150
|
/**
|
|
114
151
|
* Returns a promise that resolves when the map has mounted in the DOM.
|
|
115
152
|
*/
|
|
@@ -137,14 +174,10 @@ export interface MapModel extends EventSource<MapModelEvents> {
|
|
|
137
174
|
*/
|
|
138
175
|
removeHighlights(): void;
|
|
139
176
|
}
|
|
140
|
-
/** Events emitted by the {@link LayerCollection}. */
|
|
141
|
-
export interface LayerCollectionEvents {
|
|
142
|
-
changed: void;
|
|
143
|
-
}
|
|
144
177
|
/**
|
|
145
178
|
* Contains the layers known to a {@link MapModel}.
|
|
146
179
|
*/
|
|
147
|
-
export interface LayerCollection
|
|
180
|
+
export interface LayerCollection {
|
|
148
181
|
/**
|
|
149
182
|
* Returns all configured base layers.
|
|
150
183
|
*/
|
|
@@ -177,7 +210,7 @@ export interface LayerCollection extends EventSource<LayerCollectionEvents> {
|
|
|
177
210
|
/**
|
|
178
211
|
* Returns the layer identified by the `id` or undefined, if no such layer exists.
|
|
179
212
|
*/
|
|
180
|
-
getLayerById(id: string):
|
|
213
|
+
getLayerById(id: string): AnyLayer | undefined;
|
|
181
214
|
/**
|
|
182
215
|
* Returns all layers known to this collection.
|
|
183
216
|
*/
|
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";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { Group } from "ol/layer";
|
|
2
|
+
import type { LayerRetrievalOptions } from "../shared";
|
|
3
|
+
import type { ChildrenCollection, Layer, LayerBaseType, LayerConfig } from "./base";
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options to construct a {@link GroupLayer}.
|
|
6
|
+
*/
|
|
7
|
+
export interface GroupLayerConfig extends LayerConfig {
|
|
8
|
+
/**
|
|
9
|
+
* List of layers that belong to the new group layer.
|
|
10
|
+
*
|
|
11
|
+
* The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed.
|
|
12
|
+
* A layer must have a unique parent: it can only be added to the map or a single group layer.
|
|
13
|
+
*/
|
|
14
|
+
layers: Layer[];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Represents a group of layers.
|
|
18
|
+
*
|
|
19
|
+
* A group layer contains a collection of {@link Layer} children.
|
|
20
|
+
* Groups can be nested to form a hierarchy.
|
|
21
|
+
*/
|
|
22
|
+
export interface GroupLayer extends LayerBaseType {
|
|
23
|
+
readonly type: "group";
|
|
24
|
+
/**
|
|
25
|
+
* Layers contained in this group.
|
|
26
|
+
*/
|
|
27
|
+
readonly layers: GroupLayerCollection;
|
|
28
|
+
/**
|
|
29
|
+
* Raw OpenLayers group instance.
|
|
30
|
+
*
|
|
31
|
+
* **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized!
|
|
32
|
+
*/
|
|
33
|
+
readonly olLayer: Group;
|
|
34
|
+
readonly sublayers: undefined;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Contains {@link Layer} instances that belong to a {@link GroupLayer}
|
|
38
|
+
*/
|
|
39
|
+
export interface GroupLayerCollection extends ChildrenCollection<Layer> {
|
|
40
|
+
/**
|
|
41
|
+
* Returns all layers in this collection
|
|
42
|
+
*/
|
|
43
|
+
getLayers(options?: LayerRetrievalOptions): Layer[];
|
|
44
|
+
}
|
|
45
|
+
export interface GroupLayerConstructor {
|
|
46
|
+
prototype: GroupLayer;
|
|
47
|
+
/** Creates a new {@link GroupLayer}. */
|
|
48
|
+
new (config: GroupLayerConfig): GroupLayer;
|
|
49
|
+
}
|
|
50
|
+
export declare const GroupLayer: GroupLayerConstructor;
|
|
@@ -0,0 +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 } from \"../shared\";\nimport type { 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\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":";;AA6DO,MAAM,UAAoC,GAAA;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type OlBaseLayer from "ol/layer/Base";
|
|
2
|
-
import { LayerConfig,
|
|
2
|
+
import { LayerConfig, LayerBaseType } from "./base";
|
|
3
3
|
/**
|
|
4
4
|
* Options to construct a simple layer.
|
|
5
5
|
*
|
|
@@ -20,5 +20,8 @@ export interface SimpleLayerConstructor {
|
|
|
20
20
|
/**
|
|
21
21
|
* A simple layer type wrapping an OpenLayers layer.
|
|
22
22
|
*/
|
|
23
|
-
export
|
|
23
|
+
export interface SimpleLayer extends LayerBaseType {
|
|
24
|
+
readonly type: "simple";
|
|
25
|
+
readonly layers: undefined;
|
|
26
|
+
}
|
|
24
27
|
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,
|
|
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;;;;"}
|
package/api/layers/WMSLayer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Options as WMSSourceOptions } from "ol/source/ImageWMS";
|
|
2
|
-
import type { LayerBaseConfig,
|
|
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,16 @@ export interface WMSSublayerConfig extends LayerBaseConfig {
|
|
|
29
29
|
sublayers?: WMSSublayerConfig[];
|
|
30
30
|
}
|
|
31
31
|
/** Represents a WMS layer. */
|
|
32
|
-
export interface WMSLayer extends
|
|
32
|
+
export interface WMSLayer extends LayerBaseType {
|
|
33
|
+
readonly type: "wms";
|
|
33
34
|
readonly sublayers: SublayersCollection<WMSSublayer>;
|
|
35
|
+
readonly layers: undefined;
|
|
34
36
|
/** The URL of the WMS service that was used during layer construction. */
|
|
35
37
|
readonly url: string;
|
|
36
38
|
}
|
|
37
39
|
/** Represents a WMS sublayer */
|
|
38
|
-
export interface WMSSublayer extends
|
|
40
|
+
export interface WMSSublayer extends SublayerBaseType {
|
|
41
|
+
readonly type: "wms-sublayer";
|
|
39
42
|
/**
|
|
40
43
|
* The name of the WMS sublayer in the service's capabilities.
|
|
41
44
|
*
|
|
@@ -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 {
|
|
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 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":";;AA6EO,MAAM,QAAgC,GAAA;;;;"}
|