Ver código fonte

Merge branch 'feat_map' into feat_theme_zyh

zhouyuhao 11 meses atrás
pai
commit
279008e737

+ 6 - 2
src/views/Tracking/src/components/TrackingDetail/src/components/MapView.vue

@@ -55,7 +55,7 @@ const initMap = () => {
     return
   }
 
-  map = L.map('tracking-map', {}).setView([51.505, -0.09], 3)
+  map = L.map('tracking-map', { scrollWheelZoom: false }).setView([51.505, -0.09], 3)
 
   // 添加 TileLayer
   L.tileLayer('https://map.kerryapex.com/osm_tiles/{z}/{x}/{y}.png', {
@@ -530,7 +530,11 @@ onMounted(() => {
 })
 
 onUnmounted(() => {
-  map?.remove()
+  // 清除地图实例,防止内存泄漏
+  if (map) {
+    map.off() // 移除所有事件监听器
+    map.remove() // 移除地图
+  }
 })
 </script>