@dative-gpi/foundation-shared-components 1.0.40 → 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.
@@ -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
- const zoom = map.value.getZoom();
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 panTo = (lat: number, lng: number) => {
325
+ const flyTo = (lat: number, lng: number, zoom: number = defaultZoom) => {
319
326
  if(!map.value) {
320
327
  return;
321
328
  }
322
- map.value.panTo(calculateTargetPosition(latLng(lat, lng)));
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
- panTo(e.latlng.lat, e.latlng.lng);
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
- panTo(selectedLocation?.address.latitude, selectedLocation?.address.longitude);
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 { INJECTION_FSMAP_MAP } from './keys';
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>>(INJECTION_FSMAP_MAP);
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 { INJECTION_FSMAP_MAP, INJECTION_FSMAP_MARKERCLUSTERGROUP } from './keys';
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>>(INJECTION_FSMAP_MAP);
45
- const markerClusterGroup = inject<Ref<MarkerClusterGroup | null>>(INJECTION_FSMAP_MARKERCLUSTERGROUP, ref(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 { INJECTION_FSMAP_MAP } from './keys';
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>>(INJECTION_FSMAP_MAP);
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: 17,
42
+ disableClusteringAtZoom: props.disableClusteringAtZoom,
38
43
  iconCreateFunction: function (cluster: any) {
39
44
  const size = 36;
40
45
 
@@ -133,4 +133,4 @@ export default defineComponent({
133
133
  };
134
134
  }
135
135
  });
136
- </script>
136
+ </script>
@@ -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 { INJECTION_FSMAP_FEATUREGROUP, INJECTION_FSMAP_MAP } from './keys';
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>>(INJECTION_FSMAP_MAP);
29
- const featureGroup = inject<Ref<FeatureGroup | null>>(INJECTION_FSMAP_FEATUREGROUP, ref(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 { INJECTION_FSMAP_MAP } from './keys';
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>>(INJECTION_FSMAP_MAP);
21
+ const map = inject<Ref<Map | null>>(MAP);
22
22
 
23
23
  const lastLayer = props.layer;
24
24
 
@@ -1,4 +1,4 @@
1
- export const INJECTION_FSMAP_FEATUREGROUP = 'featureGroup';
2
- export const INJECTION_FSMAP_MAP = 'map';
3
- export const INJECTION_FSMAP_MARKERCLUSTERGROUP = 'markerClusterGroup';
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.40",
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.40",
14
- "@dative-gpi/foundation-shared-services": "1.0.40"
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": "a1e2c35d0e08ce37a05a56d7d7f0f477b935a645"
38
+ "gitHead": "508299773d7c9704b08daf80c858931aaa823326"
39
39
  }