@open-pioneer/map 1.4.0 → 1.5.0-dev.20260911123645
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 +534 -489
- package/README.md +5 -8
- package/layers/AbstractLayer.d.ts +6 -1
- package/layers/AbstractLayer.js +18 -4
- package/layers/AbstractLayer.js.map +1 -1
- package/layers/shared/AddLayerOptions.d.ts +3 -2
- package/layers/shared/LayerConfig.d.ts +2 -0
- package/layers/shared/internals.d.ts +1 -0
- package/layers/shared/internals.js +2 -1
- package/layers/shared/internals.js.map +1 -1
- package/model/Highlights.d.ts +3 -0
- package/model/Highlights.js +10 -0
- package/model/Highlights.js.map +1 -1
- package/model/LayerCollection.js +38 -23
- package/model/LayerCollection.js.map +1 -1
- package/model/MapConfig.d.ts +16 -0
- package/model/createMapModel.js +55 -0
- package/model/createMapModel.js.map +1 -1
- package/package.json +16 -12
- package/ui/MapContainer.js.map +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
1
1
|
# @open-pioneer/map
|
|
2
2
|
|
|
3
|
+
## 1.5.0-dev.20260911123645
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f790fda: Update to Chakra 3.37.0
|
|
8
|
+
- 38658ce: Add `setStyle` method to `Highlight` to change the style of existing highlights.
|
|
9
|
+
- ebda251: The `addLayer` method now also accepts `at: "base"` to add a base layer.
|
|
10
|
+
- ebda251: Add new properties for topmost layers and base layers in `MapConfig`.
|
|
11
|
+
|
|
12
|
+
- With `MapConfig.topmostLayers` topmost layers can now be defined in the initial map setup.
|
|
13
|
+
- Base layers can now be defined in the initial map setup with the `MapConfig.baseLayers` property
|
|
14
|
+
|
|
15
|
+
We recommend using the `baseLayers` property instead of `isBaseLayer: true` for new apps.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
export class MapConfigProviderImpl implements MapConfigProvider {
|
|
19
|
+
mapId = MAP_ID;
|
|
20
|
+
|
|
21
|
+
async getMapConfig({ layerFactory }: MapConfigProviderOptions): Promise<MapConfig> {
|
|
22
|
+
return {
|
|
23
|
+
initialView: {...},
|
|
24
|
+
projection: "EPSG:25832",
|
|
25
|
+
baseLayers: [
|
|
26
|
+
//all base layers
|
|
27
|
+
layerFactory.create(...)
|
|
28
|
+
],
|
|
29
|
+
layers: [
|
|
30
|
+
//all other operational layers
|
|
31
|
+
layerFactory.create(...),
|
|
32
|
+
layerFactory.create(...)
|
|
33
|
+
],
|
|
34
|
+
topmostLayers: [
|
|
35
|
+
//all operational highlight layers
|
|
36
|
+
layerFactory.create(...)
|
|
37
|
+
]
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- 3203815: Update code to match new react linting rules from oxlint.
|
|
46
|
+
- 09ec7c7: Updated dependencies
|
|
47
|
+
|
|
3
48
|
## 1.4.0
|
|
4
49
|
|
|
5
50
|
### Minor Changes
|
|
@@ -7,16 +52,16 @@
|
|
|
7
52
|
- c30396d: Update Chakra to 3.36.1
|
|
8
53
|
- 690a892: A layer's loadState is now a derived from three different channels:
|
|
9
54
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
55
|
+
- source — the OpenLayers source state (undefined/loading/ready/error).
|
|
56
|
+
- health — the result of the optional healthCheck (run once on attach).
|
|
57
|
+
- metadata — the result of a layer's own capabilities request (if any).
|
|
13
58
|
|
|
14
|
-
|
|
59
|
+
Additionally, a new property `loadError` has been added to the layer class.
|
|
15
60
|
|
|
16
61
|
- e4b47f1: `useMapModel` now prints an error message if the map model could not be created.
|
|
17
62
|
This error was previously returned and was easy to silently ignore.
|
|
18
63
|
|
|
19
|
-
|
|
64
|
+
Use the option `quiet: true` to suppress this error message.
|
|
20
65
|
|
|
21
66
|
- c9b3ced: Provide reactive rotation in MapModel
|
|
22
67
|
- 690a892: WMS Layer: add validation that configured sublayers actually exist in the service's capabilities.
|
|
@@ -45,17 +90,17 @@
|
|
|
45
90
|
- fcbd505: Sanitize HTML used for layer attributions.
|
|
46
91
|
- 33ab02f: Move highlight methods to `mapModel.highlights`.
|
|
47
92
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
93
|
+
- `mapModel.highlight()` -> `mapModel.highlights.add()`
|
|
94
|
+
- `mapModel.highlightAndZoom()` -> `mapModel.highlights.addAndZoom()`
|
|
95
|
+
- `mapModel.removeHighlights()` -> `mapModel.highlights.clear()`
|
|
51
96
|
|
|
52
|
-
|
|
97
|
+
The old methods on the Map Model have been deprecated and will be removed in a future major release.
|
|
53
98
|
|
|
54
99
|
- d54ccfd: Update to Chakra UI 3.35.0
|
|
55
100
|
- 33ab02f: Add new `mapModel.overlays` API to render arbitrary React content on the map at certain coordinates.
|
|
56
101
|
This can be helpful for feature info, popups and for tooltips during map interactions.
|
|
57
102
|
|
|
58
|
-
|
|
103
|
+
Use `mapModel.overlay.add({ content: <SomeReactContent />, ...})` to create a new overlay.
|
|
59
104
|
|
|
60
105
|
- 206b397: Update to trails core packages 4.6.0
|
|
61
106
|
- 2ceb1ca: MapContainer: allow configuration of `rootProps` and `containerProps`.
|
|
@@ -94,22 +139,22 @@
|
|
|
94
139
|
Using only a minimum or maximum limit is possible.
|
|
95
140
|
Missing properties are considered as no limitation.
|
|
96
141
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
142
|
+
```js
|
|
143
|
+
layerFactory.create({
|
|
144
|
+
type: WMTSLayer,
|
|
145
|
+
isBaseLayer: true,
|
|
146
|
+
title: "Basemap",
|
|
147
|
+
name: "basemap",
|
|
148
|
+
minZoom: 10,
|
|
149
|
+
maxZoom: 16,
|
|
150
|
+
});
|
|
151
|
+
```
|
|
107
152
|
|
|
108
|
-
|
|
153
|
+
The boolean property `visibleInScale` of a layer indicates the visibility of this layer depending on the current resolution of the map.
|
|
109
154
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
155
|
+
Restrictions of a `GroupLayer` are inherited to child layers.
|
|
156
|
+
If no restrictions are configured for a child layer, its visibility limitations are equal to the parent `GroupLayer`.
|
|
157
|
+
By configuring additional limits for the child layer, its visibility can be further restricted.
|
|
113
158
|
|
|
114
159
|
### Patch Changes
|
|
115
160
|
|
|
@@ -122,233 +167,233 @@
|
|
|
122
167
|
- b3709f1: **Breaking:** Remove layer constructor types from public API (e.g. `SimpleLayerConstructor`).
|
|
123
168
|
- 9e9bc6e: **Breaking**: Internal layers are no longer returned from getters such as `getItems()` or `getRecursiveLayers()` by default.
|
|
124
169
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
A new option `includeInternalLayers` has been implemented to opt-in into internal layers.
|
|
171
|
+
By default, internal layers are not returned by functions like `getItems()` or `getRecursiveLayers()`.
|
|
172
|
+
If internal layer should be returned this must be specified explicitly with the `includeInternalLayers` option.
|
|
128
173
|
|
|
129
|
-
|
|
130
|
-
|
|
174
|
+
```js
|
|
175
|
+
import { MapModel } from "@open-pioneer/map";
|
|
131
176
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
177
|
+
//internal layers are not included
|
|
178
|
+
const layers = myMapModel.layers.getItems();
|
|
179
|
+
//include internal layers
|
|
180
|
+
const allLayers = myMapModel.layers.getItems({ includeInternalLayers: true });
|
|
181
|
+
```
|
|
137
182
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
183
|
+
Note that if internal layers are returned this includes system layers (e.g. for highlights or geolocation) that were not explicitly added to the map.
|
|
184
|
+
The described behavior is aligned for the functions `getItems()`, `getLayers()`, `getAllLayers()` and `getRecursiveLayers()` in `LayerCollection`, `WMSLayer` and `GroupLayer`.
|
|
185
|
+
The function `getRecursiveLayers()` does not return non-internal child layers of an internal layer.
|
|
141
186
|
|
|
142
187
|
- b3709f1: **Breaking:** Remove old event API from layer types and the map model.
|
|
143
188
|
|
|
144
|
-
|
|
189
|
+
These were only used for the `"destroy"` event.
|
|
145
190
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
191
|
+
```ts
|
|
192
|
+
// OLD, removed API:
|
|
193
|
+
const layer = ...;
|
|
194
|
+
layer.on("destroyed", () => {
|
|
195
|
+
console.debug("layer was destroyed");
|
|
196
|
+
});
|
|
197
|
+
```
|
|
153
198
|
|
|
154
|
-
|
|
199
|
+
The destroy event still exists, but is now based on the event system of the [reactivity API](https://github.com/conterra/reactivity/tree/main/packages/reactivity-events):
|
|
155
200
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
201
|
+
```ts
|
|
202
|
+
// NEW
|
|
203
|
+
import { on } from "@conterra/reactivity-events";
|
|
159
204
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
205
|
+
const layer = ...;
|
|
206
|
+
on(layer.destroyed, () => {
|
|
207
|
+
console.debug("layer was destroyed");
|
|
208
|
+
});
|
|
164
209
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
210
|
+
const mapModel = ...;
|
|
211
|
+
on(mapModel.destroyed, () => {
|
|
212
|
+
console.debug("layer was destroyed");
|
|
213
|
+
});
|
|
214
|
+
```
|
|
170
215
|
|
|
171
216
|
- a1614de: **Breaking**: Remove support for `mapId` in all React components.
|
|
172
217
|
|
|
173
|
-
|
|
174
|
-
|
|
218
|
+
To configure the map for a component (for example: `Legend`), either pass the `map`
|
|
219
|
+
as an explicit parameter or use the `DefaultMapProvider`:
|
|
175
220
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
221
|
+
```ts
|
|
222
|
+
// Explicit API
|
|
223
|
+
<Legend map={map} />
|
|
179
224
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
225
|
+
// All children of the DefaultMapProvider can use the configured map
|
|
226
|
+
<DefaultMapProvider map={map}>
|
|
227
|
+
<MapContainer />
|
|
228
|
+
<Legend />
|
|
229
|
+
<SomeOtherComponent />
|
|
230
|
+
</DefaultMapProvider>;
|
|
231
|
+
```
|
|
187
232
|
|
|
188
|
-
|
|
233
|
+
Support for `mapId` was removed in [PR #486](https://github.com/open-pioneer/trails-openlayers-base-packages/pull/486).
|
|
189
234
|
|
|
190
235
|
### Minor Changes
|
|
191
236
|
|
|
192
237
|
- 29a10df: Support buffer for zoom geometries.
|
|
193
238
|
Use the `buffer` option to specify the size increase. E.g. `0.1` for 10% size increase.
|
|
194
239
|
|
|
195
|
-
|
|
240
|
+
We use the already existing `calculateBufferedExtent` function to compute the buffer.
|
|
196
241
|
|
|
197
|
-
|
|
242
|
+
For example:
|
|
198
243
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
244
|
+
```ts
|
|
245
|
+
const map: MapModel = ...;
|
|
246
|
+
const highlight = map.highlightAndZoom(someGeometries, {
|
|
247
|
+
// Grows extent by 10%
|
|
248
|
+
buffer: 0.1
|
|
249
|
+
});
|
|
250
|
+
```
|
|
206
251
|
|
|
207
252
|
- 2702df4: Introduce `internal` property for all layer types (including sublayers).
|
|
208
253
|
If `internal` is `true` (default: `false`) the layer is not considered by any UI widget (e.g. Legend and Toc).
|
|
209
254
|
The `internal` state of a layer is not to be confused with the layer's visibility on the map which is determined by the `visible` property.
|
|
210
255
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
256
|
+
```typescript
|
|
257
|
+
//internal layer is visible on the map but hidden in UI elements like legend and Toc
|
|
258
|
+
const internalLayer = new SimpleLayer({
|
|
259
|
+
id: "layer1",
|
|
260
|
+
title: "layer 1",
|
|
261
|
+
olLayer: myOlLayer,
|
|
262
|
+
visible: true,
|
|
263
|
+
internal: true,
|
|
264
|
+
});
|
|
265
|
+
```
|
|
221
266
|
|
|
222
267
|
- 5df900f: Add a new hook `useMapModelValue(props?)`.
|
|
223
268
|
The hook returns either the directly configured `map` (via props) or the default map from a parent `DefaultMapProvider`.
|
|
224
269
|
If neither is present, an error will be thrown.
|
|
225
270
|
|
|
226
|
-
|
|
227
|
-
|
|
271
|
+
This hook is used in all components that work with the map.
|
|
272
|
+
The typical usage works like this:
|
|
228
273
|
|
|
229
|
-
|
|
230
|
-
|
|
274
|
+
```ts
|
|
275
|
+
import { MapModelProps, useMapModelValue } from "@open-pioneer/map";
|
|
231
276
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
277
|
+
// optional `map` property inherited from `MapModelProps`
|
|
278
|
+
export interface MyComponentProps extends MapModelProps {
|
|
279
|
+
// ... other properties
|
|
280
|
+
}
|
|
236
281
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
282
|
+
export function MyComponent(props) {
|
|
283
|
+
const map = useMapModelValue(props); // looks up the map
|
|
284
|
+
}
|
|
285
|
+
```
|
|
241
286
|
|
|
242
|
-
|
|
287
|
+
You can also call this hook without any arguments:
|
|
243
288
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
289
|
+
```ts
|
|
290
|
+
// Map model from DefaultMapProvider or an error.
|
|
291
|
+
const mapModel = useMapModelValue();
|
|
292
|
+
```
|
|
248
293
|
|
|
249
|
-
|
|
294
|
+
This hook should replace _most_ usages `useMapModel`, which can't return the map model directly since it may not have finished construction yet.
|
|
250
295
|
|
|
251
296
|
- 14c484e: Introduce the `LayerFactory` service (interface `"map.LayerFactory"`).
|
|
252
297
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
298
|
+
The layer factory should be used to construct new layer instances, instead of calling the layer constructor directly.
|
|
299
|
+
Calling the constructor directly (e.g. `new SimpleLayer`) is deprecated (but still fully supported).
|
|
300
|
+
|
|
301
|
+
For example:
|
|
302
|
+
|
|
303
|
+
```ts
|
|
304
|
+
// OLD
|
|
305
|
+
new SimpleLayer({
|
|
306
|
+
title: "OSM",
|
|
307
|
+
isBaseLayer: true,
|
|
308
|
+
olLayer: new TileLayer({
|
|
309
|
+
source: new OSM(),
|
|
310
|
+
}),
|
|
311
|
+
});
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
```ts
|
|
315
|
+
// NEW
|
|
316
|
+
const layerFactory = ...; // injected
|
|
317
|
+
layerFactory.create({
|
|
318
|
+
type: SimpleLayer,
|
|
319
|
+
title: "OSM",
|
|
320
|
+
isBaseLayer: true,
|
|
321
|
+
olLayer: new TileLayer({
|
|
322
|
+
source: new OSM()
|
|
323
|
+
})
|
|
324
|
+
});
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
This was done to support passing hidden dependencies from the layer factory to the layer instance (such as the `HttpService`),
|
|
328
|
+
without forcing the user to supply these dependencies manually.
|
|
329
|
+
|
|
330
|
+
The `MapConfigProvider` has been updated as well.
|
|
331
|
+
The `getMapConfig` method will now receive the layer factory as an option.
|
|
332
|
+
This makes it easy to migrate to the new API:
|
|
333
|
+
|
|
334
|
+
```diff
|
|
335
|
+
# Example MapConfigProvider
|
|
336
|
+
export class MapConfigProviderImpl implements MapConfigProvider {
|
|
337
|
+
mapId = MAP_ID;
|
|
338
|
+
|
|
339
|
+
- async getMapConfig(): Promise<MapConfig> {
|
|
340
|
+
+ async getMapConfig({ layerFactory }: MapConfigProviderOptions): Promise<MapConfig> {
|
|
341
|
+
return {
|
|
342
|
+
initialView: {
|
|
343
|
+
kind: "position",
|
|
344
|
+
center: { x: 404747, y: 5757920 },
|
|
345
|
+
zoom: 14
|
|
346
|
+
},
|
|
347
|
+
layers: [
|
|
348
|
+
- new SimpleLayer({
|
|
349
|
+
+ layerFactory.create({
|
|
350
|
+
+ type: SimpleLayer,
|
|
351
|
+
title: "OSM",
|
|
352
|
+
isBaseLayer: true,
|
|
353
|
+
olLayer: new TileLayer({
|
|
354
|
+
source: new OSM()
|
|
355
|
+
})
|
|
356
|
+
})
|
|
357
|
+
]
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
```
|
|
317
362
|
|
|
318
363
|
- aeb9000: Add new `"topmost"` option to add layers that are always displayed on top (above all other layers).
|
|
319
364
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
365
|
+
A new layers can be added at `topmost` to ensure that this layer will always be displayed on top of the other layers.
|
|
366
|
+
This can be used, for example, to implement highlights or to draw graphics.
|
|
367
|
+
Layers added at `"topmost"` will always be shown above layers at `"top"`.
|
|
323
368
|
|
|
324
|
-
|
|
369
|
+
When using the `"above"` or `"below"` options with a `"topmost"` reference layer, that layer becomes `"topmost"` as well.
|
|
325
370
|
|
|
326
|
-
|
|
327
|
-
|
|
371
|
+
```typescript
|
|
372
|
+
import { MapModel, SimpleLayer } from "@open-pioneer/map";
|
|
328
373
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
374
|
+
const highlightLayer = new SimpleLayer({
|
|
375
|
+
title: "highlights",
|
|
376
|
+
olLayer: myOlLayer,
|
|
377
|
+
});
|
|
378
|
+
//always displayed at the top
|
|
379
|
+
myMapModel.layers.addLayer(highlightLayer, { at: "topmost" });
|
|
380
|
+
```
|
|
336
381
|
|
|
337
382
|
- 5df900f: Deprecate the parameter-less signature of `useMapModel()`:
|
|
338
383
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
384
|
+
```ts
|
|
385
|
+
// Returns the DefaultMapProvider's map, but wrapped in a result value (loading/resolved/rejected)
|
|
386
|
+
const result = useMapModel();
|
|
387
|
+
```
|
|
343
388
|
|
|
344
|
-
|
|
389
|
+
Use `useMapModelValue()` instead:
|
|
345
390
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
391
|
+
```ts
|
|
392
|
+
// Returns the map model directly.
|
|
393
|
+
const mapModel = useMapModelValue();
|
|
394
|
+
```
|
|
350
395
|
|
|
351
|
-
|
|
396
|
+
All other signatures of `useMapModel()` are still fully supported.
|
|
352
397
|
|
|
353
398
|
- 773fa2d: The map now has an appropriate focus outline style by default, which respects the map view's padding.
|
|
354
399
|
For information on disabling this behavior, see the map package documentation.
|
|
@@ -366,8 +411,8 @@
|
|
|
366
411
|
- 4f1e7bd: The internal constant `TOPMOST_LAYER_Z` has been removed.
|
|
367
412
|
To configure a layer that is always on top:
|
|
368
413
|
|
|
369
|
-
|
|
370
|
-
|
|
414
|
+
- Create a layer using the `LayerFactory`
|
|
415
|
+
- Add it to the map model and specify the `at: "topmost"` option
|
|
371
416
|
|
|
372
417
|
- 2c8b617: Introduce `MapRegistry.createMapModel` method to create a `MapModel` without a `MapConfigProvider`.
|
|
373
418
|
For more details, see [PR](https://github.com/open-pioneer/trails-openlayers-base-packages/pull/499) and [issue](https://github.com/open-pioneer/trails-openlayers-base-packages/issues/483).
|
|
@@ -382,13 +427,13 @@
|
|
|
382
427
|
- 66179bc: Update to core-packages v4.0.0
|
|
383
428
|
- acd5115: **Breaking:** Remove the following hooks, which were deprecated since version 0.8.0:
|
|
384
429
|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
430
|
+
- useView
|
|
431
|
+
- useProjection
|
|
432
|
+
- useResolution
|
|
433
|
+
- useCenter
|
|
434
|
+
- useScale
|
|
390
435
|
|
|
391
|
-
|
|
436
|
+
Use reactive properties on the map model instead, e.g. `mapModel.scale`.
|
|
392
437
|
|
|
393
438
|
- 738390e: Update to Chakra v3
|
|
394
439
|
|
|
@@ -396,30 +441,30 @@
|
|
|
396
441
|
|
|
397
442
|
- 738390e: Fix an issue with "raw" map container children that are not wrapped in a map anchor.
|
|
398
443
|
|
|
399
|
-
|
|
444
|
+
Consider, for example, the following snippet:
|
|
400
445
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
446
|
+
```tsx
|
|
447
|
+
<MapContainer>
|
|
448
|
+
{/* .custom-content does absolute positioning relative to map container */}
|
|
449
|
+
<div className="custom-content">Hi</div>
|
|
450
|
+
</MapContainer>
|
|
451
|
+
```
|
|
407
452
|
|
|
408
|
-
|
|
409
|
-
|
|
453
|
+
Previously, the `div` was rendered relative to the map container div but did _not_ respect the map's view padding.
|
|
454
|
+
Now the `div` will move according to the map padding as well.
|
|
410
455
|
|
|
411
456
|
- 0a8ff71: The default attribution widget created for the map now has `role="region"` and an `aria-label` for improved screen reader support.
|
|
412
457
|
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
458
|
+
```html
|
|
459
|
+
<div
|
|
460
|
+
style="pointer-events: auto;"
|
|
461
|
+
class="ol-attribution ol-unselectable ol-control ol-uncollapsible"
|
|
462
|
+
role="region"
|
|
463
|
+
aria-label="Quellenangaben"
|
|
464
|
+
>
|
|
465
|
+
<!-- Attributions -->
|
|
466
|
+
</div>
|
|
467
|
+
```
|
|
423
468
|
|
|
424
469
|
## 0.10.0
|
|
425
470
|
|
|
@@ -428,82 +473,82 @@
|
|
|
428
473
|
- 193068a: Deprecate the `mapId` property on React components.
|
|
429
474
|
Use the `MapModel` directly instead to pass a reference to the map.
|
|
430
475
|
|
|
431
|
-
|
|
476
|
+
Example:
|
|
432
477
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
478
|
+
```tsx
|
|
479
|
+
// Default map for entire component tree
|
|
480
|
+
<DefaultMapProvider map={mapModel}>
|
|
481
|
+
<Toc />
|
|
482
|
+
</DefaultMapProvider>
|
|
438
483
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
484
|
+
// Map for specific component
|
|
485
|
+
<Toc map={mapModel} />
|
|
486
|
+
```
|
|
442
487
|
|
|
443
488
|
### Patch Changes
|
|
444
489
|
|
|
445
490
|
- 2bafdad: Top level operational layers can now be inserted at an arbitrary position.
|
|
446
491
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
492
|
+
```ts
|
|
493
|
+
const mapModel = ...;
|
|
494
|
+
const newLayer = new SimpleLayer({
|
|
495
|
+
title: "New layer",
|
|
496
|
+
// ...
|
|
497
|
+
});
|
|
453
498
|
|
|
454
|
-
|
|
455
|
-
|
|
499
|
+
mapModel.layers.addLayer(newLayer, { at: "top" }); // Same as default: on top of all existing operational layers
|
|
500
|
+
mapModel.layers.addLayer(newLayer, { at: "bottom" }); // Below all other operational layers
|
|
456
501
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
502
|
+
const otherLayer = ...; // Eiter a valid layer id or a layer instance. Must be from the same collection.
|
|
503
|
+
mapModel.layers.addLayer(newLayer, { at: "above", reference: otherLayer }); // Above the reference layer
|
|
504
|
+
mapModel.layers.addLayer(newLayer, { at: "below", reference: otherLayer }); // Below the reference layer
|
|
505
|
+
```
|
|
461
506
|
|
|
462
507
|
- cd1435b: Update ol to 10.5.0
|
|
463
508
|
- 032eed7: Bump dependencies.
|
|
464
509
|
- cd1435b: Update to react 19.1.0
|
|
465
510
|
- 7558df4: Add new map anchor positioning options.
|
|
466
511
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
512
|
+
The following positions are now supported:
|
|
513
|
+
|
|
514
|
+
```ts
|
|
515
|
+
export type MapAnchorPosition =
|
|
516
|
+
| "manual"
|
|
517
|
+
| "top-left"
|
|
518
|
+
| "top-right"
|
|
519
|
+
| "top-center"
|
|
520
|
+
| "bottom-left"
|
|
521
|
+
| "bottom-right"
|
|
522
|
+
| "bottom-center"
|
|
523
|
+
| "left-center"
|
|
524
|
+
| "right-center"
|
|
525
|
+
| "center";
|
|
526
|
+
```
|
|
527
|
+
|
|
528
|
+
You can use `manual` positioning to position an anchor using CSS.
|
|
529
|
+
For example:
|
|
530
|
+
|
|
531
|
+
```tsx
|
|
532
|
+
<MapAnchor className="manual-position" position="manual">
|
|
533
|
+
<Box
|
|
534
|
+
backgroundColor="whiteAlpha.800"
|
|
535
|
+
borderWidth="1px"
|
|
536
|
+
borderRadius="lg"
|
|
537
|
+
padding={2}
|
|
538
|
+
boxShadow="lg"
|
|
539
|
+
>
|
|
540
|
+
Manually positioned anchor
|
|
541
|
+
</Box>
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
Combined with css:
|
|
545
|
+
|
|
546
|
+
```css
|
|
547
|
+
.manual-position {
|
|
548
|
+
left: 200px;
|
|
549
|
+
top: 200px;
|
|
550
|
+
}
|
|
551
|
+
```
|
|
507
552
|
|
|
508
553
|
## 0.9.0
|
|
509
554
|
|
|
@@ -511,8 +556,8 @@
|
|
|
511
556
|
|
|
512
557
|
- e7fdc5d: improve scale calculation for none-metric projections
|
|
513
558
|
|
|
514
|
-
|
|
515
|
-
|
|
559
|
+
Fix scale calculation for projections with none-metric units (e.g. EPSG:4326).
|
|
560
|
+
Note: The calculated scale (`useScale`) still may deviate from the desired scale (`setScale`) for non-metric projections. This is due to limitiations in the [getPointResolution](https://openlayers.org/en/latest/apidoc/module-ol_proj.html#.getPointResolution) function from OL.
|
|
516
561
|
|
|
517
562
|
- cb94c75: update dependencies
|
|
518
563
|
- f327eec: Deprecate `mapModel.layers.getAllLayers()`.
|
|
@@ -520,43 +565,43 @@
|
|
|
520
565
|
The name of `getAllLayers()` is misleading because it does not recurse into nested layers.
|
|
521
566
|
- f327eec: Add function `getRecursiveLayers()` to `LayerCollection`, `SublayerCollection` and `GroupLayerCollection` in `@open-pioneer/map`
|
|
522
567
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
568
|
+
Compared to `getLayers` and `getOperationalLayers`, `getRecursiveLayer` returns all (nested) child and sub layers of a collection.
|
|
569
|
+
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.
|
|
570
|
+
|
|
571
|
+
The function might be costly if the hierarchy of layers is deeply nested because the layer tree has to be traversed recursively.
|
|
572
|
+
In some scenarios using `options.filter` could be used to improve the performance because it is not necessary to traverse the layer tree completely if some layers are excluded.
|
|
573
|
+
|
|
574
|
+
Example (using GroupLayerCollection):
|
|
575
|
+
|
|
576
|
+
```typescript
|
|
577
|
+
const grouplayer = new GroupLayer({
|
|
578
|
+
id: "group",
|
|
579
|
+
title: "group test",
|
|
580
|
+
layers: [
|
|
581
|
+
new SimpleLayer({
|
|
582
|
+
id: "member",
|
|
583
|
+
title: "group member",
|
|
584
|
+
olLayer: olLayer1,
|
|
585
|
+
}),
|
|
586
|
+
new GroupLayer({
|
|
587
|
+
id: "subgroup",
|
|
588
|
+
title: "subgroup test",
|
|
535
589
|
layers: [
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
})
|
|
552
|
-
]
|
|
553
|
-
});
|
|
554
|
-
|
|
555
|
-
// Returns only the layer "member" because the provided filter function excludes "subgroup" and (implicitly) its child "subgroupmember".
|
|
556
|
-
const layers = grouplayer.layers.getRecursiveLayers({
|
|
557
|
-
filter: (layer) => layer.id !== "subgroup"
|
|
558
|
-
});
|
|
559
|
-
```
|
|
590
|
+
new SimpleLayer({
|
|
591
|
+
id: "subgroupmember",
|
|
592
|
+
title: "subgroup member",
|
|
593
|
+
olLayer: olLayer2,
|
|
594
|
+
}),
|
|
595
|
+
],
|
|
596
|
+
}),
|
|
597
|
+
],
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
// Returns only the layer "member" because the provided filter function excludes "subgroup" and (implicitly) its child "subgroupmember".
|
|
601
|
+
const layers = grouplayer.layers.getRecursiveLayers({
|
|
602
|
+
filter: (layer) => layer.id !== "subgroup",
|
|
603
|
+
});
|
|
604
|
+
```
|
|
560
605
|
|
|
561
606
|
### Patch Changes
|
|
562
607
|
|
|
@@ -564,23 +609,23 @@
|
|
|
564
609
|
This allows specifying the type of the `properties` attribute.
|
|
565
610
|
The default type is `Readonly<Record<string, unknown>>` for backwards compatibility.
|
|
566
611
|
|
|
567
|
-
|
|
612
|
+
Example:
|
|
568
613
|
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
614
|
+
```ts
|
|
615
|
+
interface MyFeatureProperties {
|
|
616
|
+
name: string;
|
|
617
|
+
}
|
|
573
618
|
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
619
|
+
const feature: BaseFeature<MyFeatureProperties> = {
|
|
620
|
+
id: 123,
|
|
621
|
+
properties: {
|
|
622
|
+
name: "Example Feature",
|
|
623
|
+
},
|
|
624
|
+
};
|
|
580
625
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
626
|
+
// string | undefined instead of `unknown`
|
|
627
|
+
const name = feature.properties?.name;
|
|
628
|
+
```
|
|
584
629
|
|
|
585
630
|
- 32ed2cd: Fix `mapModel.layers.getLayerById()` not being reactive (#400).
|
|
586
631
|
- 209eb8e: Added a configuration option to disable fetching of WMS service capabilities.
|
|
@@ -594,126 +639,126 @@
|
|
|
594
639
|
- e7978a8: **Breaking:** Remove most events from the map model and the layer interfaces.
|
|
595
640
|
All events that were merely used to synchronized state (e.g. `changed:title` etc.) have been removed.
|
|
596
641
|
|
|
597
|
-
|
|
598
|
-
|
|
642
|
+
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).
|
|
643
|
+
This change greatly simplifies the code that is necessary to access up-to-date values and to react to changes.
|
|
599
644
|
|
|
600
|
-
|
|
645
|
+
For example, from inside a React component, you can now write:
|
|
601
646
|
|
|
602
|
-
|
|
603
|
-
|
|
647
|
+
```jsx
|
|
648
|
+
import { useReactiveSnapshot } from "@open-pioneer/reactivity";
|
|
604
649
|
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
650
|
+
function YourComponent() {
|
|
651
|
+
// Always up to date, even if the layer's title changes.
|
|
652
|
+
// No more need to listen to events.
|
|
653
|
+
const title = useReactiveSnapshot(() => layer.title, [layer]);
|
|
654
|
+
return <div>{title}</div>;
|
|
655
|
+
}
|
|
656
|
+
```
|
|
612
657
|
|
|
613
|
-
|
|
658
|
+
And inside a normal JavaScript function, you can watch for changes like this:
|
|
614
659
|
|
|
615
|
-
|
|
616
|
-
|
|
660
|
+
```js
|
|
661
|
+
import { watch } from "@conterra/reactivity-core";
|
|
617
662
|
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
663
|
+
const watchHandle = watch(
|
|
664
|
+
() => [layer.title],
|
|
665
|
+
([newTitle]) => {
|
|
666
|
+
console.log("The title changed to", newTitle);
|
|
667
|
+
}
|
|
668
|
+
);
|
|
624
669
|
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
670
|
+
// Later, cleanup:
|
|
671
|
+
watchHandle.destroy();
|
|
672
|
+
```
|
|
628
673
|
|
|
629
|
-
|
|
674
|
+
For more details, check the [Reactivity API documentation](https://github.com/conterra/reactivity/blob/main/packages/reactivity-core/README.md).
|
|
630
675
|
|
|
631
676
|
- 7ae9f90: Add new `children` property to all layers.
|
|
632
677
|
This property makes it possible to handle any layer children in a generic fashion, regardless of the layer's actual type.
|
|
633
678
|
|
|
634
|
-
|
|
679
|
+
`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.
|
|
635
680
|
|
|
636
681
|
- d8337a6: The following hooks are deprecated and will be removed in a future release:
|
|
637
682
|
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
683
|
+
- `useView`
|
|
684
|
+
- `useProjection`
|
|
685
|
+
- `useResolution`
|
|
686
|
+
- `useCenter`
|
|
687
|
+
- `useScale`
|
|
643
688
|
|
|
644
|
-
|
|
689
|
+
They can all be replaced by using the new reactive properties on the `MapModel`, for example:
|
|
645
690
|
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
691
|
+
```javascript
|
|
692
|
+
// old:
|
|
693
|
+
const center = useCenter(olMap);
|
|
649
694
|
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
695
|
+
// new:
|
|
696
|
+
const center = useReactiveSnapshot(() => mapModel.center, [mapModel]);
|
|
697
|
+
```
|
|
653
698
|
|
|
654
699
|
- 2fa8020: Update trails core package dependencies.
|
|
655
700
|
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
701
|
+
- Also updates Chakra UI to the latest 2.x version and Chakra React Select to version 5.
|
|
702
|
+
- Removes any obsolete references to `@chakra-ui/system`.
|
|
703
|
+
This dependency seems to be no longer required and may lead to duplicate packages in your dependency tree.
|
|
659
704
|
|
|
660
705
|
- 7ae9f90: Add new layer type `GroupLayer` to to the Map API.
|
|
661
706
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
707
|
+
A `GroupLayer` contains a list of `Layer` (e.g. `SimpleLayer` or `WMSLayer`). Because `GroupLayer` is a `Layer` as well nested groups are supported.
|
|
708
|
+
The child layers of a `GroupLayer` can be accessed with the `layers` property - `layers` is `undefined` if it is not a group.
|
|
709
|
+
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).
|
|
710
|
+
|
|
711
|
+
```js
|
|
712
|
+
const olLayer1 = new TileLayer({
|
|
713
|
+
source: new OSM(),
|
|
714
|
+
});
|
|
715
|
+
const olLayer2 = new TileLayer({
|
|
716
|
+
source: new BkgTopPlusOpen(),
|
|
717
|
+
});
|
|
718
|
+
|
|
719
|
+
// Create group layer with nested sub group
|
|
720
|
+
const group = new GroupLayer({
|
|
721
|
+
id: "group",
|
|
722
|
+
title: "a group layer",
|
|
723
|
+
layers: [
|
|
724
|
+
new SimpleLayer({
|
|
725
|
+
id: "member",
|
|
726
|
+
title: "group member",
|
|
727
|
+
olLayer: olLayer1,
|
|
728
|
+
}),
|
|
729
|
+
new GroupLayer({
|
|
730
|
+
id: "subgroup",
|
|
731
|
+
title: "a nested group layer",
|
|
732
|
+
layers: [
|
|
733
|
+
new SimpleLayer({
|
|
734
|
+
id: "submember",
|
|
735
|
+
title: "subgroup member",
|
|
736
|
+
olLayer: olLayer2,
|
|
737
|
+
}),
|
|
738
|
+
],
|
|
739
|
+
}),
|
|
740
|
+
],
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
const childLayers: GroupLayerCollection = group.layers; // Access child layers
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
Layers can only be added to a single group or map.
|
|
747
|
+
Sublayers (e.g. `WMSSublayer`) cannot be added to a group directly.
|
|
703
748
|
|
|
704
749
|
- d8337a6: Provide new reactive properties on the `MapModel` type.
|
|
705
750
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
751
|
+
- `olView` (-> `olMap.getView()`)
|
|
752
|
+
- `projection` (-> `olMap.getView().getProjection()`)
|
|
753
|
+
- `resolution` (-> `olMap.getView().getResolution()`)
|
|
754
|
+
- `zoomLevel` (-> `olMap.getView().getZoom()`)
|
|
755
|
+
- `center` (-> `olMap.getView().getCenter()`)
|
|
756
|
+
- `scale` (derived from center and resolution)
|
|
712
757
|
|
|
713
|
-
|
|
714
|
-
|
|
758
|
+
Most of the listed properties are already available on raw OpenLayers objects (see code in parentheses above).
|
|
759
|
+
However, those OpenLayers properties require manual work for synchronization, whereas the new properties are reactive (and can be watched, for example, using `useReactiveSnapshot()`).
|
|
715
760
|
|
|
716
|
-
|
|
761
|
+
A new method `setScale()` has also been added to the model.
|
|
717
762
|
|
|
718
763
|
### Patch Changes
|
|
719
764
|
|
|
@@ -727,45 +772,45 @@
|
|
|
727
772
|
|
|
728
773
|
- 2502050: Introduce union types and `type` attributes for layers. This allows TypeScript narrowing for layers and determining a layer's type.
|
|
729
774
|
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
775
|
+
The `Layer` and `Sublayer` types for layers remain, but are unions of the corresponding concrete layer types now.
|
|
776
|
+
The layer type `LayerBase` has been removed and is replaced by `AnyLayerType`
|
|
777
|
+
to clarify that this type represents a union of all types of layer (currently `Layer` and `Sublayer`).
|
|
733
778
|
|
|
734
|
-
|
|
779
|
+
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).
|
|
735
780
|
|
|
736
|
-
|
|
781
|
+
The following `type` attribute values have been implemented at the layers:
|
|
737
782
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
783
|
+
- SimpleLayer: `simple`
|
|
784
|
+
- WMSLayer: `wms`
|
|
785
|
+
- WMSSubLayer: `wms-sublayer`
|
|
786
|
+
- WMTSLayer: `wmts`
|
|
742
787
|
|
|
743
|
-
|
|
788
|
+
Example of usage:
|
|
744
789
|
|
|
745
|
-
|
|
746
|
-
|
|
790
|
+
```ts
|
|
791
|
+
import { AnyLayer, WMTSLayer, isSublayer } from "@open-pioneer/map";
|
|
747
792
|
|
|
748
|
-
|
|
749
|
-
|
|
793
|
+
export class ExampleClass {
|
|
794
|
+
//...
|
|
750
795
|
|
|
751
|
-
|
|
752
|
-
|
|
796
|
+
exampleFunction(layer: AnyLayer) {
|
|
797
|
+
// prop may be a layer of any type
|
|
753
798
|
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
799
|
+
// use layers type attribute to check layer type
|
|
800
|
+
if (layer.type === "wmts") {
|
|
801
|
+
layer.matrixSet; // prop only available on WMTSLayer
|
|
757
802
|
|
|
758
|
-
|
|
759
|
-
|
|
803
|
+
const wmtsLayer: WMTSLayer = layer; // type of layer is now narrowed to `WMTSLayer`
|
|
804
|
+
}
|
|
760
805
|
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
806
|
+
// use new type guard to check if layer is a Sublayer
|
|
807
|
+
if (isSublayer(layer)) {
|
|
808
|
+
// type of layer is now narrowed to `WMSSublayer` (as it is currently the only type of Sublayer existing)
|
|
809
|
+
layer.parentLayer; // prop only available on Sublayers
|
|
810
|
+
}
|
|
767
811
|
}
|
|
768
|
-
|
|
812
|
+
}
|
|
813
|
+
```
|
|
769
814
|
|
|
770
815
|
- 310800c: Switch from `peerDependencies` to normal `dependencies`. Peer dependencies have some usability problems when used at scale.
|
|
771
816
|
|
|
@@ -775,7 +820,7 @@
|
|
|
775
820
|
- 583f1d6: The `mapId` or `map` properties are now optional on individual components.
|
|
776
821
|
You can use the `DefaultMapProvider` to configure an implicit default value.
|
|
777
822
|
|
|
778
|
-
|
|
823
|
+
Note that configuring _neither_ a default _nor_ an explicit `map` or `mapId` will trigger a runtime error.
|
|
779
824
|
|
|
780
825
|
- 583f1d6: All UI components in this project now accept the `mapId` (a `string`) _or_ the `map` (a `MapModel`) directly.
|
|
781
826
|
- 397d617: Reimplement computation of map anchor positioning using new css props.
|
|
@@ -785,20 +830,20 @@
|
|
|
785
830
|
- 583f1d6: The new component `DefaultMapProvider` allows you to configure the _default map_ for its children.
|
|
786
831
|
If `DefaultMapProvider` is used, you can omit the explicit `mapId` (or `map`) property on the individual UI components.
|
|
787
832
|
|
|
788
|
-
|
|
833
|
+
For many applications, `DefaultMapProvider` can be used to surround all (or most of) the application's UI.
|
|
789
834
|
|
|
790
|
-
|
|
835
|
+
Example:
|
|
791
836
|
|
|
792
|
-
|
|
793
|
-
|
|
837
|
+
```tsx
|
|
838
|
+
import { DefaultMapProvider } from "@open-pioneer/map";
|
|
794
839
|
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
840
|
+
<DefaultMapProvider mapId={MAP_ID}>
|
|
841
|
+
{/* no need to repeat the map id in this subtree, unless you want to use a different one */}
|
|
842
|
+
<MapContainer />
|
|
843
|
+
<Toc />
|
|
844
|
+
<ComplexChild />
|
|
845
|
+
</DefaultMapProvider>;
|
|
846
|
+
```
|
|
802
847
|
|
|
803
848
|
- 397d617: Move attribution of OL map according to the map view's padding.
|
|
804
849
|
|
|
@@ -815,36 +860,36 @@
|
|
|
815
860
|
|
|
816
861
|
- 0d51d2f: Change how map anchors are positioned in the DOM.
|
|
817
862
|
|
|
818
|
-
|
|
863
|
+
Previously, map anchor divs were children of the OpenLayers map viewport:
|
|
819
864
|
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
865
|
+
```
|
|
866
|
+
.map-container
|
|
867
|
+
└── .ol-viewport
|
|
868
|
+
└── .ol-overlaycontainer-stopevent
|
|
869
|
+
└── .map-anchors
|
|
870
|
+
└── .map-anchor
|
|
871
|
+
└── ... children ...
|
|
872
|
+
```
|
|
828
873
|
|
|
829
|
-
|
|
830
|
-
|
|
874
|
+
This interfered with browser event handling, especially if the map anchor's content was interactive.
|
|
875
|
+
The workarounds to stop events from map-anchors to bubble into the map caused surprising behavior (e.g. https://github.com/open-pioneer/trails-openlayers-base-packages/issues/312).
|
|
831
876
|
|
|
832
|
-
|
|
877
|
+
Now, the DOM looks like this:
|
|
833
878
|
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
879
|
+
```
|
|
880
|
+
.map-container
|
|
881
|
+
├── .map-anchors
|
|
882
|
+
│ └── .map-anchor
|
|
883
|
+
│ └── ... children ...
|
|
884
|
+
└── .ol-viewport
|
|
885
|
+
```
|
|
841
886
|
|
|
842
|
-
|
|
887
|
+
Which means that the map-anchors are no longer children of the map.
|
|
843
888
|
|
|
844
|
-
|
|
889
|
+
You may have to update your custom styles if you relied on the previous DOM hierarchy.
|
|
845
890
|
|
|
846
|
-
|
|
847
|
-
|
|
891
|
+
The `MapAnchor`'s prop `stopEvents` has been deleted as it is no longer needed.
|
|
892
|
+
Browser events happening inside a map anchor or its children will no longer affect the map.
|
|
848
893
|
|
|
849
894
|
### Patch Changes
|
|
850
895
|
|