@rural-environmental-registry/map_component 2.0.4 → 2.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rural-environmental-registry/map_component",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Map component for Vue.js applications",
5
5
  "main": "dist/index.mjs",
6
6
  "module": "dist/index.mjs",
@@ -46,7 +46,7 @@
46
46
 
47
47
  <script lang="ts" setup>
48
48
  import L from 'leaflet'
49
- import { computed, ref } from 'vue'
49
+ import { computed, ref, shallowRef } from 'vue'
50
50
  import {
51
51
  DrawingEvent,
52
52
  GroupActionConfig,
@@ -133,7 +133,7 @@
133
133
  toggleMeasureArea: () => void
134
134
  }
135
135
 
136
- const mapRef = ref<MapRef>()
136
+ const mapRef = shallowRef<MapRef>()
137
137
  const mapContainerRef = ref<HTMLElement | null>(null)
138
138
  const coordinatePanelRef = ref()
139
139
  const isLoading = ref<boolean>(false)
@@ -7,7 +7,7 @@
7
7
 
8
8
  <script setup lang="ts">
9
9
  import L from 'leaflet'
10
- import { nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
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 = ref<L.Map>()
49
- const layerControl = ref<L.Control.Layers>()
50
- const drawItemsGroup = ref<L.FeatureGroup>()
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
@@ -36,7 +36,7 @@
36
36
  <script lang="ts" setup>
37
37
  import { ElButton, ElMenu } from 'element-plus'
38
38
  import L from 'leaflet'
39
- import { computed, nextTick, ref, watch } from 'vue'
39
+ import { computed, markRaw, nextTick, ref, shallowRef, toRaw, watch } from 'vue'
40
40
  import FontAwesomeIcon from '../fa-icon/FontAwesomeIcon.vue'
41
41
  import SectionMenu from './SectionMenu.vue'
42
42
  import {
@@ -89,8 +89,8 @@
89
89
  const props = defineProps<MenuProps>()
90
90
 
91
91
  const isMenuOpen = ref<boolean>(!!props.options?.defaultOpen)
92
- const convertedLayers = ref<ConvertedLayers>({})
93
- const convertedGeoJsonLayers = ref<ConvertedGeoJsonLayers>({})
92
+ const convertedLayers = shallowRef<ConvertedLayers>({})
93
+ const convertedGeoJsonLayers = shallowRef<ConvertedGeoJsonLayers>({})
94
94
  const internalEditingLayerKey = ref<string | null>(null)
95
95
  const internalSelectedSectionKey = ref<string | null>(null)
96
96
 
@@ -318,7 +318,7 @@
318
318
  initDefaultLayers()
319
319
  })
320
320
  },
321
- { immediate: true, deep: true }
321
+ { immediate: true }
322
322
  )
323
323
 
324
324
  const onChildLayerChange = (layer: LayerData): void => {
@@ -389,13 +389,15 @@
389
389
 
390
390
  if (!layer.active) return
391
391
 
392
- const wmsLayer = convertToWmsLayer(layer)
392
+ const wmsLayer = markRaw(convertToWmsLayer(layer))
393
393
  convertedLayers.value[layer.key] = wmsLayer
394
394
 
395
- wmsLayer.addTo(props.map)
395
+ const rawMap = toRaw(props.map)
396
+ wmsLayer.addTo(rawMap)
396
397
 
397
- if (props.layerControl) {
398
- props.layerControl.addOverlay(wmsLayer, `${wmsLayer.options.attribution}`)
398
+ const rawLayerControl = props.layerControl ? toRaw(props.layerControl) : null
399
+ if (rawLayerControl) {
400
+ rawLayerControl.addOverlay(wmsLayer, `${wmsLayer.options.attribution}`)
399
401
  }
400
402
  }
401
403
 
@@ -403,8 +405,9 @@
403
405
  const wmsLayer = convertedLayers.value[layer.key]
404
406
  if (!wmsLayer) return
405
407
 
406
- props.map.removeLayer(wmsLayer)
407
- props.layerControl?.removeLayer(wmsLayer)
408
+ const rawMap = toRaw(props.map)
409
+ rawMap.removeLayer(wmsLayer)
410
+ toRaw(props.layerControl)?.removeLayer(wmsLayer)
408
411
 
409
412
  delete convertedLayers.value[layer.key]
410
413
  }
@@ -443,13 +446,15 @@
443
446
 
444
447
  if (!layer.active) return
445
448
 
446
- const geoJsonLayer = convertToGeojsonLayer(layer)
449
+ const geoJsonLayer = markRaw(convertToGeojsonLayer(layer))
447
450
  convertedGeoJsonLayers.value[layer.key] = geoJsonLayer
448
451
 
449
- geoJsonLayer.addTo(props.map)
452
+ const rawMap = toRaw(props.map)
453
+ geoJsonLayer.addTo(rawMap)
450
454
 
451
- if (props.layerControl) {
452
- props.layerControl.addOverlay(geoJsonLayer, `${geoJsonLayer.options.attribution}`)
455
+ const rawLayerControl = props.layerControl ? toRaw(props.layerControl) : null
456
+ if (rawLayerControl) {
457
+ rawLayerControl.addOverlay(geoJsonLayer, `${geoJsonLayer.options.attribution}`)
453
458
  }
454
459
  }
455
460
 
@@ -457,8 +462,9 @@
457
462
  const geoJsonLayer = convertedGeoJsonLayers.value[layer.key]
458
463
  if (!geoJsonLayer) return
459
464
 
460
- props.map.removeLayer(geoJsonLayer)
461
- props.layerControl?.removeLayer(geoJsonLayer)
465
+ const rawMap = toRaw(props.map)
466
+ rawMap.removeLayer(geoJsonLayer)
467
+ toRaw(props.layerControl)?.removeLayer(geoJsonLayer)
462
468
 
463
469
  delete convertedGeoJsonLayers.value[layer.key]
464
470
  }
@@ -508,4 +514,4 @@
508
514
  border-color: var(--mapa-base-white);
509
515
  }
510
516
  }
511
- </style>
517
+ </style>