@eox/layercontrol 0.22.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/eox-layercontrol.js +836 -839
- package/dist/eox-layercontrol.umd.cjs +119 -122
- package/package.json +9 -13
- package/src/components/add-layers.js +416 -0
- package/src/components/layer-config.js +212 -0
- package/src/components/layer-datetime.js +128 -0
- package/src/components/layer-group.js +193 -0
- package/src/components/layer-legend.js +135 -0
- package/src/components/layer-list.js +209 -0
- package/src/components/layer-tools.js +353 -0
- package/src/components/layer.js +244 -0
- package/src/components/optional-list.js +124 -0
- package/src/components/tab-sliders.js +0 -0
- package/src/components/tools-items.js +199 -0
- package/src/enums/index.js +16 -0
- package/src/enums/stories/assets/cropomhusc-feature-collection.json +5274 -0
- package/src/enums/stories/index.js +536 -0
- package/src/helpers/check-properties.js +41 -0
- package/src/helpers/clean-json-input.js +29 -0
- package/src/helpers/create-sortable.js +104 -0
- package/src/helpers/detect-map-url-type.js +20 -0
- package/src/helpers/fetch-capabilities.js +32 -0
- package/src/helpers/filter-layers.js +45 -0
- package/src/helpers/get-layer-type.js +35 -0
- package/src/helpers/get-legend-config.js +25 -0
- package/src/helpers/get-start-vals.js +73 -0
- package/src/helpers/hide-layers-based-on-property.js +11 -0
- package/src/helpers/index.js +22 -0
- package/src/helpers/is-layer-json-valid.js +19 -0
- package/src/helpers/is-layer-visible-based-on-zoom-state.js +31 -0
- package/src/helpers/is-layer-zoom-state-req.js +17 -0
- package/src/helpers/is-map-url-valid.js +22 -0
- package/src/helpers/layer-tools.js +82 -0
- package/src/helpers/update-url.js +32 -0
- package/src/main.js +269 -0
- package/src/methods/add-layer/add-layer.js +33 -0
- package/src/methods/add-layer/index.js +8 -0
- package/src/methods/add-layer/json-input-change.js +15 -0
- package/src/methods/add-layer/open-close-tab.js +21 -0
- package/src/methods/add-layer/url-input-change.js +17 -0
- package/src/methods/add-layer/url-layer.js +37 -0
- package/src/methods/add-layer/wms-search-url.js +44 -0
- package/src/methods/layer/first-updated.js +65 -0
- package/src/methods/layer/index.js +4 -0
- package/src/methods/layer/input-click.js +43 -0
- package/src/methods/layer-config/apply-updated-styles.js +98 -0
- package/src/methods/layer-config/data-change.js +44 -0
- package/src/methods/layer-config/index.js +7 -0
- package/src/methods/layer-list/first-updated.js +55 -0
- package/src/methods/layer-list/index.js +3 -0
- package/src/methods/layercontrol/first-update.js +22 -0
- package/src/methods/layercontrol/index.js +4 -0
- package/src/methods/layercontrol/layer-list-change.js +23 -0
- package/src/methods/optional-list/add-to-list.js +44 -0
- package/src/methods/optional-list/index.js +3 -0
- package/test/_mockMap.js +0 -154
- package/test/cases/general/check-layer-legend.js +0 -67
- package/test/cases/general/check-layer-size.js +0 -25
- package/test/cases/general/check-pre-open-layer-tools.js +0 -26
- package/test/cases/general/check-pre-open-section.js +0 -29
- package/test/cases/general/disable-drag.js +0 -26
- package/test/cases/general/empty-groups.js +0 -41
- package/test/cases/general/exclusive-layers.js +0 -35
- package/test/cases/general/hide-layers.js +0 -23
- package/test/cases/general/index.js +0 -10
- package/test/cases/general/render-optional-layer.js +0 -31
- package/test/cases/general/show-layer-title.js +0 -23
- package/test/cases/layer-update/add-external-layer.js +0 -96
- package/test/cases/layer-update/add-layer-from-optional.js +0 -51
- package/test/cases/layer-update/check-if-layer-pushed-to-group.js +0 -33
- package/test/cases/layer-update/check-layer-changed-event.js +0 -29
- package/test/cases/layer-update/check-layer-is-pushed-to-root.js +0 -22
- package/test/cases/layer-update/check-layer-removed-from-group.js +0 -33
- package/test/cases/layer-update/check-layer-removed-from-root.js +0 -27
- package/test/cases/layer-update/check-layer-size-after-multiple-calls.js +0 -34
- package/test/cases/layer-update/check-layer-zoom-state.js +0 -54
- package/test/cases/layer-update/index.js +0 -9
- package/test/general.cy.js +0 -61
- package/test/layersUpdate.cy.js +0 -72
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { when } from "lit/directives/when.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* `EOxLayerControlLayerDatetime` is a component that handles date time options for layers using eox-timecontrol.
|
|
6
|
+
* It triggers an event of the currently selected datetime value; allowing users to show and update a specific layer for a specific time.
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* @element eox-layercontrol-layer-datetime
|
|
10
|
+
* @extends LitElement
|
|
11
|
+
*/
|
|
12
|
+
export class EOxLayerControlLayerDatetime extends LitElement {
|
|
13
|
+
// Define static properties for the component
|
|
14
|
+
static properties = {
|
|
15
|
+
unstyled: { type: Boolean },
|
|
16
|
+
noShadow: { type: Boolean },
|
|
17
|
+
layerDatetime: { attribute: false },
|
|
18
|
+
layer: { attribute: false },
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Render the element without additional styles
|
|
26
|
+
*
|
|
27
|
+
* @type {Boolean}
|
|
28
|
+
*/
|
|
29
|
+
this.unstyled = false;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Renders the element without a shadow root
|
|
33
|
+
*
|
|
34
|
+
* @type {Boolean}
|
|
35
|
+
*/
|
|
36
|
+
this.noShadow = false;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Layer config for eox-jsonform
|
|
40
|
+
*
|
|
41
|
+
* @type {{
|
|
42
|
+
* disablePlay?: boolean;
|
|
43
|
+
* slider?: boolean;
|
|
44
|
+
* currentStep: string|number;
|
|
45
|
+
* controlValues: (string|number)[]
|
|
46
|
+
* }}
|
|
47
|
+
*/
|
|
48
|
+
this.layerDatetime = null;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The native OL layer
|
|
52
|
+
*
|
|
53
|
+
* @type {import("ol/layer").Layer}
|
|
54
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html}
|
|
55
|
+
*/
|
|
56
|
+
this.layer = null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Overrides createRenderRoot to handle shadow DOM creation based on the noShadow property.
|
|
61
|
+
*/
|
|
62
|
+
createRenderRoot() {
|
|
63
|
+
return this.noShadow ? this : super.createRenderRoot();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Handles timecontrol Stepchange &
|
|
68
|
+
* triggers `datetime:updated` event on step change
|
|
69
|
+
*
|
|
70
|
+
* @param {CustomEvent<{currentStep:string|number}>} evt
|
|
71
|
+
**/
|
|
72
|
+
#handleStepChange(evt) {
|
|
73
|
+
this.dispatchEvent(
|
|
74
|
+
new CustomEvent("datetime:updated", {
|
|
75
|
+
bubbles: true,
|
|
76
|
+
detail: {
|
|
77
|
+
datetime: evt.detail.currentStep,
|
|
78
|
+
layer: this.layer,
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
this.layerDatetime.currentStep = evt.detail.currentStep;
|
|
84
|
+
this.requestUpdate();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Renders a Time Control for datetime options of a layer.
|
|
89
|
+
*/
|
|
90
|
+
render() {
|
|
91
|
+
if (!customElements.get("eox-timecontrol")) {
|
|
92
|
+
console.error(
|
|
93
|
+
"Please import @eox/timecontrol in order to use layerDatetime",
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return html`
|
|
97
|
+
<style>
|
|
98
|
+
${this.#styleBasic}
|
|
99
|
+
${!this.unstyled && this.#styleEOX}
|
|
100
|
+
</style>
|
|
101
|
+
${when(
|
|
102
|
+
this.layerDatetime,
|
|
103
|
+
() => html`
|
|
104
|
+
<!-- Render a Timecontrol for layer date time -->
|
|
105
|
+
<eox-timecontrol
|
|
106
|
+
?unstyled=${this.unstyled}
|
|
107
|
+
.for=${undefined}
|
|
108
|
+
.layer=${undefined}
|
|
109
|
+
.slider=${this.layerDatetime.slider ?? false}
|
|
110
|
+
.disablePlay=${this.layerDatetime.disablePlay ?? false}
|
|
111
|
+
.controlValues=${this.layerDatetime.controlValues}
|
|
112
|
+
.controlProperty=${undefined}
|
|
113
|
+
current-step=${this.layerDatetime.currentStep}
|
|
114
|
+
@stepchange=${this.#handleStepChange}
|
|
115
|
+
></eox-timecontrol>
|
|
116
|
+
`,
|
|
117
|
+
)}
|
|
118
|
+
`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#styleBasic = ``;
|
|
122
|
+
#styleEOX = ``;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
customElements.define(
|
|
126
|
+
"eox-layercontrol-layer-datetime",
|
|
127
|
+
EOxLayerControlLayerDatetime,
|
|
128
|
+
);
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import { LitElement, html, nothing } from "lit";
|
|
2
|
+
import { when } from "lit/directives/when.js";
|
|
3
|
+
import { hideLayersBasedOnProperties } from "../helpers";
|
|
4
|
+
import "./layer";
|
|
5
|
+
import "./layer-list";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Custom element representing a group of layers within a layer control.
|
|
9
|
+
* Handles rendering a layer control group with expandable details containing layers.
|
|
10
|
+
*
|
|
11
|
+
* @element eox-layercontrol-layer-group
|
|
12
|
+
* @extends LitElement
|
|
13
|
+
*/
|
|
14
|
+
export class EOxLayerControlLayerGroup extends LitElement {
|
|
15
|
+
// Define static properties for the component
|
|
16
|
+
static properties = {
|
|
17
|
+
group: { attribute: false },
|
|
18
|
+
idProperty: { attribute: "id-property" },
|
|
19
|
+
map: { attribute: false, state: true },
|
|
20
|
+
titleProperty: { attribute: "title-property", type: String },
|
|
21
|
+
showLayerZoomState: { attribute: "show-layer-zoom-state", type: Boolean },
|
|
22
|
+
tools: { attribute: false },
|
|
23
|
+
unstyled: { type: Boolean },
|
|
24
|
+
noShadow: { type: Boolean },
|
|
25
|
+
toolsAsList: { type: Boolean },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The native OL layer group
|
|
33
|
+
*
|
|
34
|
+
* @type {import("ol/layer").Group}
|
|
35
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_layer_Group-LayerGroup.html}
|
|
36
|
+
*/
|
|
37
|
+
this.group = null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* The layer id property
|
|
41
|
+
*
|
|
42
|
+
* @type {String}
|
|
43
|
+
*/
|
|
44
|
+
this.idProperty = "id";
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The native OL map
|
|
48
|
+
* @type {import("ol").Map}
|
|
49
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html}
|
|
50
|
+
*/
|
|
51
|
+
this.map = null;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The layer title property
|
|
55
|
+
*
|
|
56
|
+
* @type {String}
|
|
57
|
+
*/
|
|
58
|
+
this.titleProperty = "title";
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Show layer state based on zoom level or not
|
|
62
|
+
*
|
|
63
|
+
* @type {Boolean}
|
|
64
|
+
*/
|
|
65
|
+
this.showLayerZoomState = false;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Represents an array of tools.
|
|
69
|
+
*
|
|
70
|
+
* @type {Array<string>}
|
|
71
|
+
*/
|
|
72
|
+
this.tools = [];
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Render the element without additional styles
|
|
76
|
+
*
|
|
77
|
+
* @type {Boolean}
|
|
78
|
+
*/
|
|
79
|
+
this.unstyled = false;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Renders the element without a shadow root
|
|
83
|
+
*
|
|
84
|
+
* @type {Boolean}
|
|
85
|
+
*/
|
|
86
|
+
this.noShadow = false;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* If enabled, the tools section will be rendered as list.
|
|
90
|
+
*
|
|
91
|
+
* @type {Boolean}
|
|
92
|
+
*/
|
|
93
|
+
this.toolsAsList = false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Overrides the default behavior of creating the render root element.
|
|
98
|
+
* If 'noShadow' is set to true, returns 'this'; otherwise, falls back to the default behavior
|
|
99
|
+
* of creating a shadow root using 'super.createRenderRoot()'.
|
|
100
|
+
*/
|
|
101
|
+
createRenderRoot() {
|
|
102
|
+
return this.noShadow ? this : super.createRenderRoot();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Renders a layer control group with expandable details containing layers.
|
|
107
|
+
*/
|
|
108
|
+
render() {
|
|
109
|
+
// Check if the group should be open based on a specific control property
|
|
110
|
+
const groupOpen = Boolean(this.group?.get("layerControlExpand"));
|
|
111
|
+
const numberOfChildLayers = hideLayersBasedOnProperties(
|
|
112
|
+
this.group.getLayers(),
|
|
113
|
+
)?.length;
|
|
114
|
+
|
|
115
|
+
return html`
|
|
116
|
+
<style>
|
|
117
|
+
${this.#styleBasic}
|
|
118
|
+
${!this.unstyled && this.#styleEOX}
|
|
119
|
+
</style>
|
|
120
|
+
${when(
|
|
121
|
+
this.group,
|
|
122
|
+
() => html`
|
|
123
|
+
<!-- Render the details element with the layer control -->
|
|
124
|
+
<details
|
|
125
|
+
open=${groupOpen || nothing}
|
|
126
|
+
data-children-length=${numberOfChildLayers}
|
|
127
|
+
>
|
|
128
|
+
<summary>
|
|
129
|
+
<!-- Render the layer control within the summary -->
|
|
130
|
+
<eox-layercontrol-layer
|
|
131
|
+
.noShadow=${true}
|
|
132
|
+
.layer=${this.group}
|
|
133
|
+
.map=${this.map}
|
|
134
|
+
.titleProperty=${this.titleProperty}
|
|
135
|
+
.showLayerZoomState=${this.showLayerZoomState}
|
|
136
|
+
.tools=${this.tools}
|
|
137
|
+
.unstyled=${this.unstyled}
|
|
138
|
+
.toolsAsList=${this.toolsAsList}
|
|
139
|
+
@changed=${() => this.requestUpdate()}
|
|
140
|
+
></eox-layercontrol-layer>
|
|
141
|
+
</summary>
|
|
142
|
+
|
|
143
|
+
<!-- Render the list of layers within the details -->
|
|
144
|
+
<eox-layercontrol-layer-list
|
|
145
|
+
.noShadow=${true}
|
|
146
|
+
.idProperty=${this.idProperty}
|
|
147
|
+
.layers=${this.group.getLayers()}
|
|
148
|
+
.map=${this.map}
|
|
149
|
+
.titleProperty=${this.titleProperty}
|
|
150
|
+
.showLayerZoomState=${this.showLayerZoomState}
|
|
151
|
+
.tools=${this.tools}
|
|
152
|
+
.unstyled=${this.unstyled}
|
|
153
|
+
.toolsAsList=${this.toolsAsList}
|
|
154
|
+
@changed=${() => this.requestUpdate()}
|
|
155
|
+
></eox-layercontrol-layer-list>
|
|
156
|
+
</details>
|
|
157
|
+
`,
|
|
158
|
+
)}
|
|
159
|
+
`;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
#styleBasic = ``;
|
|
163
|
+
#styleEOX = `
|
|
164
|
+
details summary {
|
|
165
|
+
cursor: pointer;
|
|
166
|
+
display: flex;
|
|
167
|
+
}
|
|
168
|
+
details summary { list-style-type: none; } /* Firefox */
|
|
169
|
+
details summary::-webkit-details-marker { display: none; } /* Chrome */
|
|
170
|
+
details summary::marker { display: none; }
|
|
171
|
+
details summary::before {
|
|
172
|
+
display: block;
|
|
173
|
+
content: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23004170' viewBox='0 0 24 24'%3E%3Ctitle%3Echevron-right%3C/title%3E%3Cpath d='M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z' /%3E%3C/svg%3E");
|
|
174
|
+
font-size: 13px;
|
|
175
|
+
width: 24px;
|
|
176
|
+
height: 24px;
|
|
177
|
+
margin: 4px 0;
|
|
178
|
+
transform-origin: center;
|
|
179
|
+
transition: transform 0.1s ease-in-out;
|
|
180
|
+
}
|
|
181
|
+
details[open] > summary:before {
|
|
182
|
+
transform: rotate(90deg);
|
|
183
|
+
}
|
|
184
|
+
details[data-children-length="0"] summary::before {
|
|
185
|
+
display: none;
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
customElements.define(
|
|
191
|
+
"eox-layercontrol-layer-group",
|
|
192
|
+
EOxLayerControlLayerGroup,
|
|
193
|
+
);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { LitElement, html, css } from "lit";
|
|
2
|
+
import { when } from "lit/directives/when.js";
|
|
3
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Legend configurations
|
|
7
|
+
*
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* domain:import("color-legend-element").ColorLegendElement["domain"]
|
|
10
|
+
* width?:number;
|
|
11
|
+
* range:string[];
|
|
12
|
+
* title?:string;
|
|
13
|
+
* tickFormat?:import("color-legend-element").ColorLegendElement["tickFormat"]
|
|
14
|
+
* ticks?:import("color-legend-element").ColorLegendElement["ticks"]
|
|
15
|
+
* tickValues?:import("color-legend-element").ColorLegendElement["tickValues"]
|
|
16
|
+
* scaleType?:import("color-legend-element").ColorLegendElement["scaleType"]
|
|
17
|
+
* markType?:import("color-legend-element").ColorLegendElement["markType"]
|
|
18
|
+
* }} LegendConfig
|
|
19
|
+
**/
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `EOxLayerControlLayerLegend` is a component that handles creating a legend from a range of colors & the domain of the color values.
|
|
23
|
+
*
|
|
24
|
+
* @element eox-layercontrol-layer-datetime
|
|
25
|
+
* @extends LitElement
|
|
26
|
+
*/
|
|
27
|
+
export class EOxLayerControlLayerLegend extends LitElement {
|
|
28
|
+
// Define static properties for the component
|
|
29
|
+
static properties = {
|
|
30
|
+
unstyled: { type: Boolean },
|
|
31
|
+
noShadow: { type: Boolean },
|
|
32
|
+
layerLegend: { attribute: false },
|
|
33
|
+
layer: { attribute: false },
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Render the element without additional styles
|
|
41
|
+
*
|
|
42
|
+
* @type {Boolean}
|
|
43
|
+
*/
|
|
44
|
+
this.unstyled = false;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Renders the element without a shadow root
|
|
48
|
+
*
|
|
49
|
+
* @type {Boolean}
|
|
50
|
+
*/
|
|
51
|
+
this.noShadow = false;
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Legend configurations
|
|
55
|
+
* @type {LegendConfig}
|
|
56
|
+
* @see {@link https://clhenrick.github.io/color-legend-element/}
|
|
57
|
+
*/
|
|
58
|
+
this.layerLegend = null;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The native OL layer
|
|
62
|
+
*
|
|
63
|
+
* @type {import("ol/layer").Layer}
|
|
64
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_layer_Layer-Layer.html}
|
|
65
|
+
*/
|
|
66
|
+
this.layer = null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Overrides createRenderRoot to handle shadow DOM creation based on the noShadow property.
|
|
71
|
+
*/
|
|
72
|
+
createRenderRoot() {
|
|
73
|
+
return this.noShadow ? this : super.createRenderRoot();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Renders a Time Control for datetime options of a layer.
|
|
78
|
+
*/
|
|
79
|
+
render() {
|
|
80
|
+
if (!customElements.get("color-legend")) {
|
|
81
|
+
console.error(
|
|
82
|
+
"Please import `color-legend-element` in order to use layerLegend",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return html`
|
|
87
|
+
<style>
|
|
88
|
+
${this.#styleBasic}
|
|
89
|
+
${!this.unstyled && this.#styleEOX}
|
|
90
|
+
</style>
|
|
91
|
+
${when(
|
|
92
|
+
this.layerLegend,
|
|
93
|
+
() => html`
|
|
94
|
+
<div class="legend-container">
|
|
95
|
+
<!-- Render color-legend-->
|
|
96
|
+
<color-legend
|
|
97
|
+
id="${this.layer.get("id")}"
|
|
98
|
+
width=${this.layerLegend.width ?? 325}
|
|
99
|
+
scaleType="${ifDefined(this.layerLegend.scaleType)}"
|
|
100
|
+
markType="${ifDefined(this.layerLegend.markType)}"
|
|
101
|
+
titleText="${ifDefined(this.layerLegend.title)}"
|
|
102
|
+
.range=${this.layerLegend.range}
|
|
103
|
+
.domain=${this.layerLegend.domain}
|
|
104
|
+
tickFormat="${ifDefined(this.layerLegend.tickFormat)}"
|
|
105
|
+
.ticks=${this.layerLegend.ticks ?? 5}
|
|
106
|
+
.tickValues=${this.layerLegend.tickValues}
|
|
107
|
+
>
|
|
108
|
+
</color-legend>
|
|
109
|
+
</div>
|
|
110
|
+
`,
|
|
111
|
+
)}
|
|
112
|
+
`;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
#styleBasic = css`
|
|
116
|
+
.legend-container {
|
|
117
|
+
display: flex;
|
|
118
|
+
justify-content: center;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
color-legend {
|
|
122
|
+
--cle-background: transparent;
|
|
123
|
+
--cle-font-family: inherit;
|
|
124
|
+
--cle-font-size: inherit;
|
|
125
|
+
--cle-font-weight: inherit --cle-letter-spacing: inherit;
|
|
126
|
+
--cle-letter-spacing-title: inherit;
|
|
127
|
+
}
|
|
128
|
+
`;
|
|
129
|
+
#styleEOX = ``;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
customElements.define(
|
|
133
|
+
"eox-layercontrol-layer-legend",
|
|
134
|
+
EOxLayerControlLayerLegend,
|
|
135
|
+
);
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { LitElement, html } from "lit";
|
|
2
|
+
import { when } from "lit/directives/when.js";
|
|
3
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
4
|
+
import { getLayerType, hideLayersBasedOnProperties } from "../helpers";
|
|
5
|
+
import "./layer";
|
|
6
|
+
import "./layer-group";
|
|
7
|
+
import { firstUpdatedMethod } from "../methods/layer-list";
|
|
8
|
+
/**
|
|
9
|
+
* EOxLayerControlLayerList: Manages a list of layers within the EOx Layer Control.
|
|
10
|
+
*
|
|
11
|
+
* @element eox-layercontrol-layer-list
|
|
12
|
+
* @extends LitElement
|
|
13
|
+
*/
|
|
14
|
+
export class EOxLayerControlLayerList extends LitElement {
|
|
15
|
+
// Define static properties for the component
|
|
16
|
+
static properties = {
|
|
17
|
+
idProperty: { attribute: "id-property" },
|
|
18
|
+
layers: { attribute: false },
|
|
19
|
+
map: { attribute: false, state: true },
|
|
20
|
+
titleProperty: { attribute: "title-property", type: String },
|
|
21
|
+
showLayerZoomState: { attribute: "show-layer-zoom-state", type: Boolean },
|
|
22
|
+
tools: { attribute: false },
|
|
23
|
+
unstyled: { type: Boolean },
|
|
24
|
+
noShadow: { type: Boolean },
|
|
25
|
+
toolsAsList: { type: Boolean },
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The layer id property
|
|
33
|
+
*
|
|
34
|
+
* @type {String}
|
|
35
|
+
*/
|
|
36
|
+
this.idProperty = "id";
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The OL layer collection
|
|
40
|
+
*
|
|
41
|
+
* @type {import("ol").Collection<import("ol/layer").Layer | import("ol/layer").Group>}
|
|
42
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_Collection-Collection.html}
|
|
43
|
+
*/
|
|
44
|
+
this.layers = null;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The native OL map
|
|
48
|
+
*
|
|
49
|
+
* @type {import("ol").Map}
|
|
50
|
+
* @see {@link https://openlayers.org/en/latest/apidoc/module-ol_Map-Map.html}
|
|
51
|
+
*/
|
|
52
|
+
this.map = null;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Represents an array of tools.
|
|
56
|
+
*
|
|
57
|
+
* @type {Array<string>}
|
|
58
|
+
*/
|
|
59
|
+
this.tools = undefined;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* The layer title property
|
|
63
|
+
*
|
|
64
|
+
* @type {String}
|
|
65
|
+
*/
|
|
66
|
+
this.titleProperty = "title";
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Show layer state based on zoom level or not
|
|
70
|
+
*
|
|
71
|
+
* @type {Boolean}
|
|
72
|
+
*/
|
|
73
|
+
this.showLayerZoomState = false;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Render the element without additional styles
|
|
77
|
+
*
|
|
78
|
+
* @type {Boolean}
|
|
79
|
+
*/
|
|
80
|
+
this.unstyled = false;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Renders the element without a shadow root
|
|
84
|
+
*
|
|
85
|
+
* @type {Boolean}
|
|
86
|
+
*/
|
|
87
|
+
this.noShadow = false;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* If enabled, the tools section will be rendered as list.
|
|
91
|
+
*
|
|
92
|
+
* @type {Boolean}
|
|
93
|
+
*/
|
|
94
|
+
this.toolsAsList = false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Executes specific logic after the initial render of the component.
|
|
99
|
+
*/
|
|
100
|
+
firstUpdated() {
|
|
101
|
+
firstUpdatedMethod(this);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Overrides createRenderRoot to handle shadow DOM creation based on the noShadow property.
|
|
106
|
+
*/
|
|
107
|
+
createRenderRoot() {
|
|
108
|
+
return this.noShadow ? this : super.createRenderRoot();
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Renders a list of layers for the EOx Layer Control component. Filters layers based on control properties and renders either
|
|
113
|
+
* layer groups or individual layers accordingly. Utilizes conditional rendering and iterates through available layers.
|
|
114
|
+
*/
|
|
115
|
+
render() {
|
|
116
|
+
// Filter and reverse layers based on control properties
|
|
117
|
+
const layers = this.layers
|
|
118
|
+
? hideLayersBasedOnProperties(this.layers).reverse()
|
|
119
|
+
: [];
|
|
120
|
+
|
|
121
|
+
return html`
|
|
122
|
+
<style>
|
|
123
|
+
${this.#styleBasic}
|
|
124
|
+
${!this.unstyled && this.#styleEOX}
|
|
125
|
+
</style>
|
|
126
|
+
<ul>
|
|
127
|
+
${when(
|
|
128
|
+
this.layers,
|
|
129
|
+
() => html`
|
|
130
|
+
${repeat(
|
|
131
|
+
layers,
|
|
132
|
+
(layer) => layer,
|
|
133
|
+
(layer) => html`
|
|
134
|
+
<li
|
|
135
|
+
data-layer="${layer.get(this.idProperty)}"
|
|
136
|
+
data-type="${getLayerType(layer, this.map)}"
|
|
137
|
+
>
|
|
138
|
+
${
|
|
139
|
+
/** Checks if the layer is a group or individual layer and renders accordingly */
|
|
140
|
+
/** @type {import("ol/layer").Group} */ (layer).getLayers
|
|
141
|
+
? html`
|
|
142
|
+
<eox-layercontrol-layer-group
|
|
143
|
+
.noShadow=${true}
|
|
144
|
+
.group=${layer}
|
|
145
|
+
.idProperty=${this.idProperty}
|
|
146
|
+
.map=${this.map}
|
|
147
|
+
.titleProperty=${this.titleProperty}
|
|
148
|
+
.showLayerZoomState=${this.showLayerZoomState}
|
|
149
|
+
.tools=${this.tools}
|
|
150
|
+
.unstyled=${this.unstyled}
|
|
151
|
+
.toolsAsList=${this.toolsAsList}
|
|
152
|
+
@changed=${() => this.requestUpdate()}
|
|
153
|
+
>
|
|
154
|
+
</eox-layercontrol-layer-group>
|
|
155
|
+
`
|
|
156
|
+
: html`
|
|
157
|
+
<eox-layercontrol-layer
|
|
158
|
+
.noShadow=${true}
|
|
159
|
+
.layer=${layer}
|
|
160
|
+
.map=${this.map}
|
|
161
|
+
.titleProperty=${this.titleProperty}
|
|
162
|
+
.showLayerZoomState=${this.showLayerZoomState}
|
|
163
|
+
.tools=${this.tools}
|
|
164
|
+
.unstyled=${this.unstyled}
|
|
165
|
+
.toolsAsList=${this.toolsAsList}
|
|
166
|
+
@changed=${() => this.requestUpdate()}
|
|
167
|
+
></eox-layercontrol-layer>
|
|
168
|
+
`
|
|
169
|
+
}
|
|
170
|
+
</li>
|
|
171
|
+
`,
|
|
172
|
+
)}
|
|
173
|
+
`,
|
|
174
|
+
)}
|
|
175
|
+
</ul>
|
|
176
|
+
`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
#styleBasic = ``;
|
|
180
|
+
#styleEOX = `
|
|
181
|
+
ul {
|
|
182
|
+
padding: 0;
|
|
183
|
+
margin: 0;
|
|
184
|
+
}
|
|
185
|
+
ul ul {
|
|
186
|
+
padding-left: 48px;
|
|
187
|
+
}
|
|
188
|
+
li {
|
|
189
|
+
list-style: none;
|
|
190
|
+
padding-left: var(--padding);
|
|
191
|
+
}
|
|
192
|
+
li {
|
|
193
|
+
border-bottom: 1px solid #0041703a;
|
|
194
|
+
}
|
|
195
|
+
li:last-child {
|
|
196
|
+
border: none;
|
|
197
|
+
}
|
|
198
|
+
li.sortable-chosen {
|
|
199
|
+
background: #eeea;
|
|
200
|
+
}
|
|
201
|
+
li.sortable-drag {
|
|
202
|
+
opacity: 0;
|
|
203
|
+
}
|
|
204
|
+
li.sortable-ghost {
|
|
205
|
+
}
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
customElements.define("eox-layercontrol-layer-list", EOxLayerControlLayerList);
|