@rural-environmental-registry/map_component 2.0.3 → 2.0.5
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 +7621 -7573
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/map/LeafletMap.vue +4 -4
- package/src/components/menu/LayerMenu.vue +10 -4
- package/src/components/menu/ParentMenu.vue +73 -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
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
<script setup lang="ts">
|
|
9
9
|
import L from 'leaflet'
|
|
10
|
-
import { nextTick, onBeforeUnmount, onMounted,
|
|
10
|
+
import { nextTick, onBeforeUnmount, onMounted, shallowRef } from 'vue'
|
|
11
11
|
import DrawingControlHandler from '../../handlers/drawingControl'
|
|
12
12
|
import MapHandler from '../../handlers/mapHandler'
|
|
13
13
|
import { DEFAULT_MAP_OPTIONS } from '../../handlers/constants'
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
|
|
46
46
|
const props = defineProps<MapProps>()
|
|
47
47
|
|
|
48
|
-
const map =
|
|
49
|
-
const layerControl =
|
|
50
|
-
const drawItemsGroup =
|
|
48
|
+
const map = shallowRef<L.Map>()
|
|
49
|
+
const layerControl = shallowRef<L.Control.Layers>()
|
|
50
|
+
const drawItemsGroup = shallowRef<L.FeatureGroup>()
|
|
51
51
|
|
|
52
52
|
let mapHandlerInstance: MapHandler | null = null
|
|
53
53
|
let mapToolsHandler: MapToolsHandler | null = null
|
|
@@ -318,7 +318,7 @@
|
|
|
318
318
|
initDefaultLayers()
|
|
319
319
|
})
|
|
320
320
|
},
|
|
321
|
-
{ immediate: true
|
|
321
|
+
{ immediate: true }
|
|
322
322
|
)
|
|
323
323
|
|
|
324
324
|
const onChildLayerChange = (layer: LayerData): void => {
|
|
@@ -358,11 +358,17 @@
|
|
|
358
358
|
}
|
|
359
359
|
|
|
360
360
|
const convertToWmsLayer = (layer: LayerData): L.TileLayer => {
|
|
361
|
-
const
|
|
361
|
+
const wmsOptions: L.WMSOptions = {
|
|
362
362
|
layers: layer.layers,
|
|
363
363
|
format: layer.format || 'image/png',
|
|
364
364
|
transparent: layer.transparent
|
|
365
|
-
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if (layer.bounds) {
|
|
368
|
+
wmsOptions.bounds = L.latLngBounds(layer.bounds)
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const wmsLayer = L.tileLayer.wms(layer.baseUrl ?? '', wmsOptions)
|
|
366
372
|
|
|
367
373
|
if (layer?.cqlFilter && layer.cqlFilter.length > 0) {
|
|
368
374
|
wmsLayer.setParams({
|
|
@@ -502,4 +508,4 @@
|
|
|
502
508
|
border-color: var(--mapa-base-white);
|
|
503
509
|
}
|
|
504
510
|
}
|
|
505
|
-
</style>
|
|
511
|
+
</style>
|
|
@@ -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%;
|
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'
|