@rural-environmental-registry/map_component 2.0.2 → 2.0.4
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/dist/index.css +1 -1
- package/dist/index.mjs +7523 -7473
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/menu/LayerMenu.vue +13 -4
- package/src/components/menu/ParentMenu.vue +73 -3
- package/src/components/menu/SectionMenu.vue +7 -3
- package/src/types/index.ts +9 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MapOptions, Layer, PathOptions, ControlOptions, ControlPosition } from 'leaflet';
|
|
1
|
+
import { MapOptions, Layer, PathOptions, ControlOptions, ControlPosition, LatLngBoundsExpression } from 'leaflet';
|
|
2
2
|
import { GeoJsonObject } from 'geojson';
|
|
3
3
|
import { PM } from '@geoman-io/leaflet-geoman-free';
|
|
4
4
|
export type FaIconName = 'check' | 'xmark' | 'chevron-right' | 'chevron-left' | 'terminal' | 'file-lines' | 'upload' | 'pencil' | 'trash' | 'chevron-down' | 'eye' | 'eye-slash' | 'circle-info' | 'circle-exclamation' | 'triangle-exclamation' | 'circle-check' | 'circle-xmark' | 'ban' | 'lock' | 'unlock' | 'thumbtack' | 'thumb-tack' | 'map-pin';
|
|
@@ -97,6 +97,7 @@ export type LayerData = {
|
|
|
97
97
|
transparent?: boolean;
|
|
98
98
|
geojson?: GeoJsonObject | GeoJsonObject[];
|
|
99
99
|
cqlFilter?: string;
|
|
100
|
+
bounds?: LatLngBoundsExpression;
|
|
100
101
|
options?: Record<string, unknown>;
|
|
101
102
|
mapSource?: 'wms' | 'geojson' | 'none' | 'consumer';
|
|
102
103
|
actions?: LayerActionConfig[];
|
package/package.json
CHANGED
|
@@ -223,8 +223,11 @@
|
|
|
223
223
|
): { sectionKey: string; layer: LayerData } | null => {
|
|
224
224
|
for (const section of normalizedSections.value) {
|
|
225
225
|
for (const group of section.groups) {
|
|
226
|
-
|
|
227
|
-
|
|
226
|
+
let found: LayerData | undefined
|
|
227
|
+
walkMenuLayers(group.layers, (layer) => {
|
|
228
|
+
if (!found && layer.key === layerKey) found = layer
|
|
229
|
+
})
|
|
230
|
+
if (found) return { sectionKey: section.key, layer: found }
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
return null
|
|
@@ -355,11 +358,17 @@
|
|
|
355
358
|
}
|
|
356
359
|
|
|
357
360
|
const convertToWmsLayer = (layer: LayerData): L.TileLayer => {
|
|
358
|
-
const
|
|
361
|
+
const wmsOptions: L.WMSOptions = {
|
|
359
362
|
layers: layer.layers,
|
|
360
363
|
format: layer.format || 'image/png',
|
|
361
364
|
transparent: layer.transparent
|
|
362
|
-
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (layer.bounds) {
|
|
368
|
+
wmsOptions.bounds = L.latLngBounds(layer.bounds)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const wmsLayer = L.tileLayer.wms(layer.baseUrl ?? '', wmsOptions)
|
|
363
372
|
|
|
364
373
|
if (layer?.cqlFilter && layer.cqlFilter.length > 0) {
|
|
365
374
|
wmsLayer.setParams({
|
|
@@ -57,7 +57,34 @@
|
|
|
57
57
|
class="parent-menu-subgroup-accordion"
|
|
58
58
|
>
|
|
59
59
|
<template #title>
|
|
60
|
-
<div class="parent-menu-subgroup-
|
|
60
|
+
<div class="parent-menu-row parent-menu-subgroup-row">
|
|
61
|
+
<div class="parent-menu-subgroup-title">{{ child.name }}</div>
|
|
62
|
+
<span
|
|
63
|
+
v-if="showSubgroupVisibilityControl(child)"
|
|
64
|
+
class="visibility-control"
|
|
65
|
+
>
|
|
66
|
+
<button
|
|
67
|
+
v-if="visibilityMode === 'eye'"
|
|
68
|
+
type="button"
|
|
69
|
+
class="visibility-eye-button"
|
|
70
|
+
:aria-label="
|
|
71
|
+
isSubgroupActive(child) ? subgroupHideLabel(child) : subgroupShowLabel(child)
|
|
72
|
+
"
|
|
73
|
+
:title="
|
|
74
|
+
isSubgroupActive(child) ? subgroupHideLabel(child) : subgroupShowLabel(child)
|
|
75
|
+
"
|
|
76
|
+
@click.stop="toggleSubgroupVisibility(idx, !isSubgroupActive(child))"
|
|
77
|
+
>
|
|
78
|
+
<FontAwesomeIcon
|
|
79
|
+
:iconName="isSubgroupActive(child) ? 'eye' : 'eye-slash'"
|
|
80
|
+
/>
|
|
81
|
+
</button>
|
|
82
|
+
<ElDivider
|
|
83
|
+
class="divider-bar"
|
|
84
|
+
direction="vertical"
|
|
85
|
+
/>
|
|
86
|
+
</span>
|
|
87
|
+
</div>
|
|
61
88
|
</template>
|
|
62
89
|
<ChildMenu
|
|
63
90
|
v-for="(nested, nestedIdx) in child.children || []"
|
|
@@ -237,7 +264,21 @@
|
|
|
237
264
|
|
|
238
265
|
const toggleableLayers = computed(() => collectToggleableLeaves(childrenLayers.value))
|
|
239
266
|
|
|
240
|
-
const
|
|
267
|
+
const showSubgroupVisibilityControl = (subgroup: LayerData): boolean => {
|
|
268
|
+
if (props.visibilityMode === 'eye') return subgroup.visibility?.show !== false
|
|
269
|
+
return false
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const subgroupShowLabel = (subgroup: LayerData): string =>
|
|
273
|
+
subgroup.visibility?.labelShow ?? showLabel.value
|
|
274
|
+
|
|
275
|
+
const subgroupHideLabel = (subgroup: LayerData): string =>
|
|
276
|
+
subgroup.visibility?.labelHide ?? hideLabel.value
|
|
277
|
+
|
|
278
|
+
const isSubgroupActive = (subgroup: LayerData): boolean =>
|
|
279
|
+
collectToggleableLeaves(subgroup.children || []).some((layer) => layer.active)
|
|
280
|
+
|
|
281
|
+
const emitGroupLayersToggle = (): void => {
|
|
241
282
|
if (props.persist) {
|
|
242
283
|
toggleableLayers.value.forEach((layer: LayerData) => setHistory(layer))
|
|
243
284
|
}
|
|
@@ -248,6 +289,30 @@
|
|
|
248
289
|
})
|
|
249
290
|
}
|
|
250
291
|
|
|
292
|
+
const toggleSubgroupVisibility = (subgroupIdx: number, active: boolean): void => {
|
|
293
|
+
const subgroup = childrenLayers.value[subgroupIdx]
|
|
294
|
+
if (!subgroup || !isMenuSubgroup(subgroup)) return
|
|
295
|
+
|
|
296
|
+
const updatedChildren = (subgroup.children || []).map((child) => ({
|
|
297
|
+
...child,
|
|
298
|
+
active
|
|
299
|
+
}))
|
|
300
|
+
|
|
301
|
+
childrenLayers.value[subgroupIdx] = {
|
|
302
|
+
...subgroup,
|
|
303
|
+
children: updatedChildren
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if (props.persist) {
|
|
307
|
+
updatedChildren.forEach((layer) => setHistory(layer))
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
emit('onGroupLayerToggle', {
|
|
311
|
+
...props.groupData,
|
|
312
|
+
layers: childrenLayers.value
|
|
313
|
+
})
|
|
314
|
+
}
|
|
315
|
+
|
|
251
316
|
const allLayersActive = computed<boolean>({
|
|
252
317
|
get: () => toggleableLayers.value.some((layer: LayerData) => layer.active),
|
|
253
318
|
set: (active: boolean) => {
|
|
@@ -262,7 +327,7 @@
|
|
|
262
327
|
return { ...layer, active }
|
|
263
328
|
})
|
|
264
329
|
|
|
265
|
-
|
|
330
|
+
emitGroupLayersToggle()
|
|
266
331
|
}
|
|
267
332
|
})
|
|
268
333
|
|
|
@@ -431,7 +496,12 @@
|
|
|
431
496
|
background-color: transparent !important;
|
|
432
497
|
}
|
|
433
498
|
|
|
499
|
+
.parent-menu .parent-menu-subgroup-row {
|
|
500
|
+
align-items: center;
|
|
501
|
+
}
|
|
502
|
+
|
|
434
503
|
.parent-menu .parent-menu-subgroup-title {
|
|
504
|
+
flex: 1;
|
|
435
505
|
font-size: var(--mapa-fs-12);
|
|
436
506
|
font-weight: 700;
|
|
437
507
|
line-height: 150%;
|
|
@@ -148,7 +148,8 @@
|
|
|
148
148
|
import {
|
|
149
149
|
resolveEditControlAction,
|
|
150
150
|
resolveLayerActions,
|
|
151
|
-
resolveLayerMetrics
|
|
151
|
+
resolveLayerMetrics,
|
|
152
|
+
walkMenuLayers
|
|
152
153
|
} from '../../utils/layersConfigNormalizer'
|
|
153
154
|
|
|
154
155
|
const DEFAULT_ACTION_STYLE: Required<LayerActionStyle> = {
|
|
@@ -226,8 +227,11 @@
|
|
|
226
227
|
): { layer: LayerData; group: GroupLayerData } | null => {
|
|
227
228
|
if (!layerKey || !section.value) return null
|
|
228
229
|
for (const group of section.value.groups) {
|
|
229
|
-
|
|
230
|
-
|
|
230
|
+
let found: LayerData | undefined
|
|
231
|
+
walkMenuLayers(group.layers, (layer) => {
|
|
232
|
+
if (!found && layer.key === layerKey) found = layer
|
|
233
|
+
})
|
|
234
|
+
if (found) return { layer: found, group }
|
|
231
235
|
}
|
|
232
236
|
return null
|
|
233
237
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
MapOptions,
|
|
3
|
+
Layer,
|
|
4
|
+
PathOptions,
|
|
5
|
+
ControlOptions,
|
|
6
|
+
ControlPosition,
|
|
7
|
+
LatLngBoundsExpression
|
|
8
|
+
} from 'leaflet'
|
|
2
9
|
import { GeoJsonObject } from 'geojson'
|
|
3
10
|
|
|
4
11
|
// @ts-ignore
|
|
@@ -139,6 +146,7 @@ export type LayerData = {
|
|
|
139
146
|
transparent?: boolean
|
|
140
147
|
geojson?: GeoJsonObject | GeoJsonObject[]
|
|
141
148
|
cqlFilter?: string
|
|
149
|
+
bounds?: LatLngBoundsExpression
|
|
142
150
|
options?: Record<string, unknown>
|
|
143
151
|
|
|
144
152
|
mapSource?: 'wms' | 'geojson' | 'none' | 'consumer'
|