-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Co-authored-by: Michael Beckemeyer <m.beckemeyer@conterra.de>
- Loading branch information
Showing
31 changed files
with
934 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
"@open-pioneer/map": minor | ||
--- | ||
|
||
Add new `children` property to all layers. | ||
This property makes it possible to handle any layer children in a generic fashion, regardless of the layer's actual type. | ||
|
||
`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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
"@open-pioneer/map": minor | ||
--- | ||
|
||
Add new layer type `GroupLayer` to to the Map API. | ||
|
||
A `GroupLayer` contains a list of `Layer` (e.g. `SimpleLayer` or `WMSLayer`). Because `GroupLayer` is a `Layer` as well nested groups are supported. | ||
The child layers of a `GroupLayer` can be accessed with the `layers` property - `layers` is `undefined` if it is not a group. | ||
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). | ||
|
||
```js | ||
const olLayer1 = new TileLayer({ | ||
source: new OSM() | ||
}); | ||
const olLayer2 = new TileLayer({ | ||
source: new BkgTopPlusOpen() | ||
}); | ||
|
||
// Create group layer with nested sub group | ||
const group = new GroupLayer({ | ||
id: "group", | ||
title: "a group layer", | ||
layers: [ | ||
new SimpleLayer({ | ||
id: "member", | ||
title: "group member", | ||
olLayer: olLayer1 | ||
}), | ||
new GroupLayer({ | ||
id: "subgroup", | ||
title: "a nested group layer", | ||
layers: [ | ||
new SimpleLayer({ | ||
id: "submember", | ||
title: "subgroup member", | ||
olLayer: olLayer2 | ||
}) | ||
] | ||
}) | ||
] | ||
}); | ||
|
||
const childLayers: GroupLayerCollection = group.layers; // Access child layers | ||
``` | ||
|
||
Layers can only be added to a single group or map. | ||
Sublayers (e.g. `WMSSublayer`) cannot be added to a group directly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@open-pioneer/toc": patch | ||
--- | ||
|
||
Implement support for `GroupLayer`. | ||
The hierarchy of (possibly nested) groups is visualized by rendering them as a tree. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@open-pioneer/toc": minor | ||
--- | ||
|
||
When showing a layer via the toc, all parent layers of that layer will also be made visible. | ||
|
||
This can be disabled by configuring `autoShowParents={false}` on the `TOC` component. | ||
|
||
```jsx | ||
// Default: true | ||
<Toc autoShowParents={false} /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer) | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import type { Group } from "ol/layer"; | ||
import { GroupLayerImpl } from "../../model/layers/GroupLayerImpl"; | ||
import type { LayerRetrievalOptions } from "../shared"; | ||
import type { ChildrenCollection, Layer, LayerBaseType, LayerConfig } from "./base"; | ||
|
||
/** | ||
* Configuration options to construct a {@link GroupLayer}. | ||
*/ | ||
export interface GroupLayerConfig extends LayerConfig { | ||
/** | ||
* List of layers that belong to the new group layer. | ||
* | ||
* The group layer takes ownership of the given layers: they will be destroyed when the parent is destroyed. | ||
* A layer must have a unique parent: it can only be added to the map or a single group layer. | ||
*/ | ||
layers: Layer[]; | ||
} | ||
|
||
/** | ||
* Represents a group of layers. | ||
* | ||
* A group layer contains a collection of {@link Layer} children. | ||
* Groups can be nested to form a hierarchy. | ||
*/ | ||
export interface GroupLayer extends LayerBaseType { | ||
readonly type: "group"; | ||
|
||
/** | ||
* Layers contained in this group. | ||
*/ | ||
readonly layers: GroupLayerCollection; | ||
|
||
/** | ||
* Raw OpenLayers group instance. | ||
* | ||
* **Warning:** Do not manipulate the collection of layers in this group directly, changes are not synchronized! | ||
*/ | ||
readonly olLayer: Group; | ||
|
||
readonly sublayers: undefined; | ||
} | ||
|
||
/** | ||
* Contains {@link Layer} instances that belong to a {@link GroupLayer} | ||
*/ | ||
export interface GroupLayerCollection extends ChildrenCollection<Layer> { | ||
/** | ||
* Returns all layers in this collection | ||
*/ | ||
getLayers(options?: LayerRetrievalOptions): Layer[]; | ||
} | ||
|
||
export interface GroupLayerConstructor { | ||
prototype: GroupLayer; | ||
|
||
/** Creates a new {@link GroupLayer}. */ | ||
new (config: GroupLayerConfig): GroupLayer; | ||
} | ||
|
||
export const GroupLayer: GroupLayerConstructor = GroupLayerImpl; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.