@dative-gpi/foundation-shared-components 1.0.136-maps3 → 1.0.136-maps4
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/components/map/FSMap.vue +15 -103
- package/components/map/FSMapMarker.vue +2 -2
- package/models/map.ts +0 -10
- package/package.json +4 -4
package/components/map/FSMap.vue
CHANGED
|
@@ -22,36 +22,6 @@
|
|
|
22
22
|
:color="ColorEnum.Primary"
|
|
23
23
|
:latlng="gpsPosition"
|
|
24
24
|
/>
|
|
25
|
-
<FSMapFeatureGroup
|
|
26
|
-
v-if="$props.areas"
|
|
27
|
-
:expected-layers="$props.areas.length"
|
|
28
|
-
@update:bounds="(bounds) => areaGroupBounds = bounds"
|
|
29
|
-
>
|
|
30
|
-
<FSMapPolygon
|
|
31
|
-
v-for="area in areas"
|
|
32
|
-
:key="area.id"
|
|
33
|
-
:color="area.color"
|
|
34
|
-
:latlngs="area.coordinates.map((coord) => ({lat: coord.latitude, lng: coord.longitude}))"
|
|
35
|
-
@click="$emit('update:selectedAreaId', area.id)"
|
|
36
|
-
/>
|
|
37
|
-
</FSMapFeatureGroup>
|
|
38
|
-
<FSMapMarkerClusterGroup
|
|
39
|
-
v-if="$props.locations"
|
|
40
|
-
:expected-layers="$props.locations.length"
|
|
41
|
-
:disableClusteringAtZoom="defaultZoom"
|
|
42
|
-
@update:bounds="(bounds) => locationGroupBounds = bounds"
|
|
43
|
-
>
|
|
44
|
-
<FSMapMarker
|
|
45
|
-
v-for="location in $props.locations"
|
|
46
|
-
:selected="location.id === $props.selectedLocationId"
|
|
47
|
-
:key="location.id"
|
|
48
|
-
:label="location.label"
|
|
49
|
-
:color="location.color ?? ColorEnum.Primary"
|
|
50
|
-
:icon="location.icon ?? 'mdi-map-marker'"
|
|
51
|
-
:latlng="{lat: location.address.latitude, lng: location.address.longitude}"
|
|
52
|
-
@click="$emit('update:selectedLocationId', location.id)"
|
|
53
|
-
/>
|
|
54
|
-
</FSMapMarkerClusterGroup>
|
|
55
25
|
<slot />
|
|
56
26
|
</template>
|
|
57
27
|
</div>
|
|
@@ -124,10 +94,9 @@ import type {} from "leaflet.markercluster";
|
|
|
124
94
|
import { map as createMap, control, tileLayer, latLngBounds, latLng, type LatLng, type FitBoundsOptions, type ZoomPanOptions, type LatLngBounds } from "leaflet";
|
|
125
95
|
|
|
126
96
|
import { useTranslations as useTranslationsProvider } from "@dative-gpi/bones-ui/composables";
|
|
127
|
-
import { type FSArea } from '@dative-gpi/foundation-shared-domain/models';
|
|
128
97
|
|
|
129
98
|
import { useBreakpoints, useColors, useSlots } from "../../composables";
|
|
130
|
-
import { ColorEnum, type
|
|
99
|
+
import { ColorEnum, type MapLayer } from "../../models";
|
|
131
100
|
|
|
132
101
|
import FSMapLayerButton from "./FSMapLayerButton.vue";
|
|
133
102
|
import FSMapOverlay from "./FSMapOverlay.vue";
|
|
@@ -137,19 +106,12 @@ import FSCol from "../FSCol.vue";
|
|
|
137
106
|
|
|
138
107
|
import FSMapMarker from "./FSMapMarker.vue";
|
|
139
108
|
import FSMapTileLayer from "./FSMapTileLayer.vue";
|
|
140
|
-
import FSMapFeatureGroup from "./FSMapFeatureGroup.vue";
|
|
141
|
-
import FSMapMarkerClusterGroup from "./FSMapMarkerClusterGroup.vue";
|
|
142
|
-
import FSMapPolygon from "./FSMapPolygon.vue";
|
|
143
109
|
|
|
144
110
|
export default defineComponent({
|
|
145
111
|
name: "FSMap",
|
|
146
112
|
components: {
|
|
147
113
|
FSMapMarker,
|
|
148
114
|
FSMapTileLayer,
|
|
149
|
-
FSMapFeatureGroup,
|
|
150
|
-
FSMapMarkerClusterGroup,
|
|
151
|
-
FSMapPolygon,
|
|
152
|
-
|
|
153
115
|
FSMapLayerButton,
|
|
154
116
|
FSMapOverlay,
|
|
155
117
|
FSButton,
|
|
@@ -193,19 +155,14 @@ export default defineComponent({
|
|
|
193
155
|
default: false
|
|
194
156
|
},
|
|
195
157
|
center: {
|
|
196
|
-
type: Array as PropType<number[]>,
|
|
158
|
+
type: Array as PropType<number[] | null>,
|
|
197
159
|
required: false,
|
|
198
|
-
default:
|
|
199
|
-
},
|
|
200
|
-
locations: {
|
|
201
|
-
type: Array as PropType<FSLocation[]>,
|
|
202
|
-
required: false,
|
|
203
|
-
default: () => [],
|
|
160
|
+
default: null
|
|
204
161
|
},
|
|
205
|
-
|
|
206
|
-
type:
|
|
162
|
+
bounds: {
|
|
163
|
+
type: Object as PropType<LatLngBounds | null>,
|
|
207
164
|
required: false,
|
|
208
|
-
default:
|
|
165
|
+
default: null
|
|
209
166
|
},
|
|
210
167
|
currentLayer: {
|
|
211
168
|
type: String as PropType<"map" | "imagery">,
|
|
@@ -216,16 +173,6 @@ export default defineComponent({
|
|
|
216
173
|
type: Array as PropType<string[]>,
|
|
217
174
|
required: false,
|
|
218
175
|
default: () => ["map", "imagery"]
|
|
219
|
-
},
|
|
220
|
-
selectedLocationId: {
|
|
221
|
-
type: String as PropType<string | null>,
|
|
222
|
-
required: false,
|
|
223
|
-
default: null
|
|
224
|
-
},
|
|
225
|
-
selectedAreaId: {
|
|
226
|
-
type: String as PropType<string | null>,
|
|
227
|
-
required: false,
|
|
228
|
-
default: null
|
|
229
176
|
}
|
|
230
177
|
},
|
|
231
178
|
emits: ["update:modelValue", "update:selectedLocationId", "update:selectedAreaId", 'update:overlayMode', 'update:currentLayer', "click:latlng"],
|
|
@@ -302,19 +249,6 @@ export default defineComponent({
|
|
|
302
249
|
return mapLayers.find((layer) => layer.name === props.currentLayer)?.layer ?? mapLayers[0].layer;
|
|
303
250
|
});
|
|
304
251
|
|
|
305
|
-
const bounds = computed<LatLngBounds | null>(() => {
|
|
306
|
-
if(!locationGroupBounds.value && !areaGroupBounds.value) {
|
|
307
|
-
return null;
|
|
308
|
-
}
|
|
309
|
-
let bounds = locationGroupBounds.value;
|
|
310
|
-
if(bounds && areaGroupBounds.value) {
|
|
311
|
-
bounds.extend(areaGroupBounds.value);
|
|
312
|
-
} else if(areaGroupBounds.value) {
|
|
313
|
-
bounds = areaGroupBounds.value;
|
|
314
|
-
}
|
|
315
|
-
return bounds as LatLngBounds;
|
|
316
|
-
});
|
|
317
|
-
|
|
318
252
|
const overlaySlots = computed(() => {
|
|
319
253
|
return Object.keys(slots).filter((slot) => slot.startsWith("overlay-")).reduce((acc, slot) => {
|
|
320
254
|
acc[slot.replace("overlay-", "")] = slots[slot];
|
|
@@ -393,11 +327,12 @@ export default defineComponent({
|
|
|
393
327
|
minZoom: 2,
|
|
394
328
|
maxZoom: 22,
|
|
395
329
|
maxBounds: latLngBounds(latLng(-90, -180), latLng(90, 180)),
|
|
396
|
-
maxBoundsViscosity: 1.0
|
|
330
|
+
maxBoundsViscosity: 1.0,
|
|
331
|
+
zoom: defaultZoom,
|
|
332
|
+
center: props.center ? latLng(props.center[0], props.center[1]) : latLng(48.85782, 2.29521)
|
|
397
333
|
};
|
|
398
334
|
|
|
399
335
|
map.value = markRaw(createMap(leafletContainer.value, mapOptions));
|
|
400
|
-
setView(props.center[0], props.center[1], defaultZoom);
|
|
401
336
|
|
|
402
337
|
map.value.on('click', (e: L.LeafletMouseEvent) => {
|
|
403
338
|
emit('click:latlng', e.latlng);
|
|
@@ -427,41 +362,18 @@ export default defineComponent({
|
|
|
427
362
|
mapResizeObserver.disconnect();
|
|
428
363
|
});
|
|
429
364
|
|
|
430
|
-
watch (() => props.center, (
|
|
431
|
-
if(!map.value) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
setView(center[0], center[1], defaultZoom);
|
|
435
|
-
});
|
|
436
|
-
|
|
437
|
-
watch (() => props.selectedLocationId, (selectedLocationId) => {
|
|
438
|
-
if(!map.value) {
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
const selectedLocation = props.locations.find((location) => location.id === selectedLocationId);
|
|
442
|
-
if(!selectedLocation) {
|
|
443
|
-
return;
|
|
444
|
-
}
|
|
445
|
-
flyTo(selectedLocation?.address.latitude, selectedLocation?.address.longitude, defaultZoom, { animate: false });
|
|
446
|
-
}, { immediate: true });
|
|
447
|
-
|
|
448
|
-
watch(() => props.selectedAreaId, (selectedAreaId) => {
|
|
449
|
-
if(!map.value) {
|
|
450
|
-
return;
|
|
451
|
-
}
|
|
452
|
-
const selectedArea = props.areas.find((area) => area.id === selectedAreaId);
|
|
453
|
-
if(!selectedArea) {
|
|
365
|
+
watch ([() => props.center, () => map.value], () => {
|
|
366
|
+
if(!map.value || !props.center) {
|
|
454
367
|
return;
|
|
455
368
|
}
|
|
456
|
-
|
|
457
|
-
fitBounds(bounds);
|
|
369
|
+
setView(props.center[0], props.center[1], defaultZoom);
|
|
458
370
|
}, { immediate: true });
|
|
459
371
|
|
|
460
|
-
watch( () =>
|
|
461
|
-
if(!map.value || !bounds) {
|
|
372
|
+
watch([() => props.bounds, () => map.value], () => {
|
|
373
|
+
if(!map.value || !props.bounds) {
|
|
462
374
|
return;
|
|
463
375
|
}
|
|
464
|
-
fitBounds(bounds, { maxZoom: defaultZoom });
|
|
376
|
+
fitBounds(props.bounds, { maxZoom: defaultZoom });
|
|
465
377
|
});
|
|
466
378
|
|
|
467
379
|
return {
|
|
@@ -82,10 +82,10 @@ export default {
|
|
|
82
82
|
iconSize: [size, size],
|
|
83
83
|
iconAnchor: [size / 2, size / 2],
|
|
84
84
|
});
|
|
85
|
-
} else if(props.variant === 'location'
|
|
85
|
+
} else if(props.variant === 'location') {
|
|
86
86
|
const size = 36;
|
|
87
87
|
icon = divIcon({
|
|
88
|
-
html: locationMarkerHtml(props.icon, getColors(props.color).base, props.label),
|
|
88
|
+
html: locationMarkerHtml(props.icon ?? "mdi-map-marker", getColors(props.color).base, props.label),
|
|
89
89
|
iconSize: [size, size],
|
|
90
90
|
className: props.selected ? 'fs-map-marker fs-map-location fs-map-location-selected' : 'fs-map-marker fs-map-location',
|
|
91
91
|
iconAnchor: [size / 2, size / 2],
|
package/models/map.ts
CHANGED
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { type Layer } from "leaflet";
|
|
2
2
|
|
|
3
|
-
import { type Address } from "@dative-gpi/foundation-shared-domain/models";
|
|
4
|
-
|
|
5
3
|
export interface MapLayer {
|
|
6
4
|
name : string;
|
|
7
5
|
label: string;
|
|
8
6
|
image: string;
|
|
9
7
|
layer: Layer;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export interface FSLocation {
|
|
13
|
-
id: string;
|
|
14
|
-
label: string;
|
|
15
|
-
icon: string | null;
|
|
16
|
-
address: Address;
|
|
17
|
-
color: string | null;
|
|
18
8
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-components",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "1.0.136-
|
|
4
|
+
"version": "1.0.136-maps4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"author": "",
|
|
11
11
|
"license": "ISC",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@dative-gpi/foundation-shared-domain": "1.0.136-
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.136-
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.136-maps4",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.136-maps4"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^1.0.0",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "8e418112ce1eb7d3d7a75e3dff0b361d8f513865"
|
|
39
39
|
}
|