@dative-gpi/foundation-shared-components 1.0.39 → 1.0.41
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 +23 -9
- package/components/map/FSMapFeatureGroup.vue +2 -2
- package/components/map/FSMapMarker.vue +3 -3
- package/components/map/FSMapMarkerClusterGroup.vue +8 -3
- package/components/map/FSMapOverlay.vue +1 -1
- package/components/map/FSMapPolygon.vue +3 -3
- package/components/map/FSMapTileLayer.vue +2 -2
- package/components/map/keys.ts +3 -3
- package/package.json +4 -4
package/components/map/FSMap.vue
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
<FSMapMarkerClusterGroup
|
|
41
41
|
v-if="$props.locations"
|
|
42
42
|
:expected-layers="$props.locations.length"
|
|
43
|
+
:disableClusteringAtZoom="defaultZoom"
|
|
43
44
|
@update:bounds="(bounds) => locationGroupBounds = bounds"
|
|
44
45
|
>
|
|
45
46
|
<FSMapMarker
|
|
@@ -116,7 +117,7 @@
|
|
|
116
117
|
</template>
|
|
117
118
|
|
|
118
119
|
<script lang="ts">
|
|
119
|
-
import { computed, defineComponent, onMounted, type Ref, provide, type PropType, ref, type StyleValue, watch } from "vue";
|
|
120
|
+
import { computed, defineComponent, onMounted, type Ref, provide, type PropType, ref, type StyleValue, watch, onUnmounted } from "vue";
|
|
120
121
|
|
|
121
122
|
import type {} from "leaflet.markercluster";
|
|
122
123
|
import { map as createMap, control, tileLayer, latLngBounds, latLng, type LatLng, LatLngBounds, type FitBoundsOptions } from "leaflet";
|
|
@@ -240,10 +241,16 @@ export default defineComponent({
|
|
|
240
241
|
const overlayHeight = ref<number>();
|
|
241
242
|
const overlayWidth = ref<number>();
|
|
242
243
|
|
|
243
|
-
const defaultZoom = 15;
|
|
244
|
-
|
|
245
244
|
provide('map', map);
|
|
246
245
|
|
|
246
|
+
const defaultZoom = 16;
|
|
247
|
+
const mapResizeObserver = new ResizeObserver(() => {
|
|
248
|
+
if(!map.value) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
map.value.invalidateSize();
|
|
252
|
+
});
|
|
253
|
+
|
|
247
254
|
const mapLayers: MapLayer[] = [
|
|
248
255
|
{
|
|
249
256
|
name: "map",
|
|
@@ -306,20 +313,20 @@ export default defineComponent({
|
|
|
306
313
|
return bounds as LatLngBounds;
|
|
307
314
|
});
|
|
308
315
|
|
|
309
|
-
const calculateTargetPosition = (target: L.LatLng) => {
|
|
316
|
+
const calculateTargetPosition = (target: L.LatLng, zoom?: number) => {
|
|
310
317
|
if(!map.value) {
|
|
311
318
|
return target;
|
|
312
319
|
}
|
|
313
|
-
|
|
320
|
+
zoom = zoom ?? map.value.getZoom();
|
|
314
321
|
const targetPoint = map.value.project(target, zoom).subtract([leftOffset.value / 2, -bottomOffset.value / 2]);
|
|
315
322
|
return map.value.unproject(targetPoint, zoom);
|
|
316
323
|
}
|
|
317
324
|
|
|
318
|
-
const
|
|
325
|
+
const flyTo = (lat: number, lng: number, zoom: number = defaultZoom) => {
|
|
319
326
|
if(!map.value) {
|
|
320
327
|
return;
|
|
321
328
|
}
|
|
322
|
-
map.value.
|
|
329
|
+
map.value.flyTo(calculateTargetPosition(latLng(lat, lng), zoom), zoom);
|
|
323
330
|
}
|
|
324
331
|
|
|
325
332
|
const setView = (lat: number, lng: number, zoom: number) => {
|
|
@@ -376,8 +383,14 @@ export default defineComponent({
|
|
|
376
383
|
return;
|
|
377
384
|
}
|
|
378
385
|
|
|
379
|
-
|
|
386
|
+
flyTo(e.latlng.lat, e.latlng.lng);
|
|
380
387
|
});
|
|
388
|
+
|
|
389
|
+
mapResizeObserver.observe(leafletContainer.value);
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
onUnmounted(() => {
|
|
393
|
+
mapResizeObserver.disconnect();
|
|
381
394
|
});
|
|
382
395
|
|
|
383
396
|
watch (() => props.center, (center) => {
|
|
@@ -395,7 +408,7 @@ export default defineComponent({
|
|
|
395
408
|
if(!selectedLocation) {
|
|
396
409
|
return;
|
|
397
410
|
}
|
|
398
|
-
|
|
411
|
+
flyTo(selectedLocation?.address.latitude, selectedLocation?.address.longitude);
|
|
399
412
|
}, { immediate: true });
|
|
400
413
|
|
|
401
414
|
watch(() => props.selectedAreaId, (selectedAreaId) => {
|
|
@@ -419,6 +432,7 @@ export default defineComponent({
|
|
|
419
432
|
|
|
420
433
|
return {
|
|
421
434
|
ColorEnum,
|
|
435
|
+
defaultZoom,
|
|
422
436
|
leafletContainer,
|
|
423
437
|
locationGroupBounds,
|
|
424
438
|
overlayHeight,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { inject, provide, ref, type Ref } from 'vue';
|
|
7
7
|
|
|
8
8
|
import { type Map, FeatureGroup } from 'leaflet';
|
|
9
|
-
import {
|
|
9
|
+
import { MAP } from './keys';
|
|
10
10
|
|
|
11
11
|
export default {
|
|
12
12
|
name: 'FSMapFeatureGroup',
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
setup(props, { emit }) {
|
|
21
|
-
const map = inject<Ref<Map | null>>(
|
|
21
|
+
const map = inject<Ref<Map | null>>(MAP);
|
|
22
22
|
let added = false;
|
|
23
23
|
|
|
24
24
|
if(!map) {
|
|
@@ -10,7 +10,7 @@ import { type Map, type DivIcon, divIcon, type LatLng, marker, type Marker, type
|
|
|
10
10
|
import { useColors } from "../../composables";
|
|
11
11
|
|
|
12
12
|
import { gpsMarkerHtml, locationMarkerHtml, pinMarkerHtml } from '../../utils/leafletMarkers';
|
|
13
|
-
import {
|
|
13
|
+
import { MAP, MARKERCLUSTERGROUP } from './keys';
|
|
14
14
|
|
|
15
15
|
export default {
|
|
16
16
|
name: 'FSMapMarker',
|
|
@@ -41,8 +41,8 @@ export default {
|
|
|
41
41
|
},
|
|
42
42
|
emits: ['click'],
|
|
43
43
|
setup(props, { emit }) {
|
|
44
|
-
const map = inject<Ref<Map | null>>(
|
|
45
|
-
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(
|
|
44
|
+
const map = inject<Ref<Map | null>>(MAP);
|
|
45
|
+
const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(MARKERCLUSTERGROUP, ref(null));
|
|
46
46
|
|
|
47
47
|
const { getColors } = useColors();
|
|
48
48
|
|
|
@@ -8,7 +8,7 @@ import { inject, provide, ref, type Ref } from 'vue';
|
|
|
8
8
|
import { type Map, MarkerClusterGroup, divIcon } from 'leaflet';
|
|
9
9
|
|
|
10
10
|
import { clusterMarkerHtml } from '../../utils/leafletMarkers';
|
|
11
|
-
import {
|
|
11
|
+
import { MAP } from './keys';
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
name: 'FSMapMarkerClusterGroup',
|
|
@@ -17,10 +17,15 @@ export default {
|
|
|
17
17
|
type: Number,
|
|
18
18
|
default: 0,
|
|
19
19
|
required: false
|
|
20
|
+
},
|
|
21
|
+
disableClusteringAtZoom: {
|
|
22
|
+
type: Number,
|
|
23
|
+
default: 17,
|
|
24
|
+
required: false
|
|
20
25
|
}
|
|
21
26
|
},
|
|
22
27
|
setup(props, { emit }) {
|
|
23
|
-
const map = inject<Ref<Map | null>>(
|
|
28
|
+
const map = inject<Ref<Map | null>>(MAP);
|
|
24
29
|
let added = false;
|
|
25
30
|
|
|
26
31
|
if(!map) {
|
|
@@ -34,7 +39,7 @@ export default {
|
|
|
34
39
|
const markerClusterGroup = ref<MarkerClusterGroup>(new MarkerClusterGroup({
|
|
35
40
|
spiderfyOnMaxZoom: false,
|
|
36
41
|
showCoverageOnHover: false,
|
|
37
|
-
disableClusteringAtZoom:
|
|
42
|
+
disableClusteringAtZoom: props.disableClusteringAtZoom,
|
|
38
43
|
iconCreateFunction: function (cluster: any) {
|
|
39
44
|
const size = 36;
|
|
40
45
|
|
|
@@ -8,7 +8,7 @@ import { inject, type PropType, onMounted, type Ref, watch, ref } from 'vue';
|
|
|
8
8
|
import { type Map, type LatLng, type Polygon, type FeatureGroup, polygon } from 'leaflet';
|
|
9
9
|
|
|
10
10
|
import { useColors } from "../../composables";
|
|
11
|
-
import {
|
|
11
|
+
import { FEATUREGROUP, MAP } from './keys';
|
|
12
12
|
|
|
13
13
|
export default {
|
|
14
14
|
name: 'FSMapPolygon',
|
|
@@ -25,8 +25,8 @@ export default {
|
|
|
25
25
|
},
|
|
26
26
|
emits: ['click'],
|
|
27
27
|
setup(props, { emit }) {
|
|
28
|
-
const map = inject<Ref<Map | null>>(
|
|
29
|
-
const featureGroup = inject<Ref<FeatureGroup | null>>(
|
|
28
|
+
const map = inject<Ref<Map | null>>(MAP);
|
|
29
|
+
const featureGroup = inject<Ref<FeatureGroup | null>>(FEATUREGROUP, ref(null));
|
|
30
30
|
|
|
31
31
|
const { getColors } = useColors();
|
|
32
32
|
|
|
@@ -7,7 +7,7 @@ import { inject, type PropType, onMounted, type Ref, watch } from 'vue';
|
|
|
7
7
|
|
|
8
8
|
import type { Map, Layer } from 'leaflet';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { MAP } from './keys';
|
|
11
11
|
|
|
12
12
|
export default {
|
|
13
13
|
name: 'FSMapTileLayer',
|
|
@@ -18,7 +18,7 @@ export default {
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
setup(props) {
|
|
21
|
-
const map = inject<Ref<Map | null>>(
|
|
21
|
+
const map = inject<Ref<Map | null>>(MAP);
|
|
22
22
|
|
|
23
23
|
const lastLayer = props.layer;
|
|
24
24
|
|
package/components/map/keys.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const
|
|
2
|
-
export const
|
|
3
|
-
export const
|
|
1
|
+
export const FEATUREGROUP = 'featureGroup';
|
|
2
|
+
export const MAP = 'map';
|
|
3
|
+
export const MARKERCLUSTERGROUP = 'markerClusterGroup';
|
|
4
4
|
|
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.
|
|
4
|
+
"version": "1.0.41",
|
|
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.
|
|
14
|
-
"@dative-gpi/foundation-shared-services": "1.0.
|
|
13
|
+
"@dative-gpi/foundation-shared-domain": "1.0.41",
|
|
14
|
+
"@dative-gpi/foundation-shared-services": "1.0.41"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@dative-gpi/bones-ui": "^0.0.75",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"sass": "1.71.1",
|
|
36
36
|
"sass-loader": "13.3.2"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "508299773d7c9704b08daf80c858931aaa823326"
|
|
39
39
|
}
|