Explorar o código

fix: 移除图层

刘秀芳 hai 2 semanas
pai
achega
b9f7070659
Modificáronse 2 ficheiros con 10 adicións e 2 borrados
  1. 2 2
      src/views/warningHome/index.vue
  2. 8 0
      src/views/warningHome/map/alarmLayer.js

+ 2 - 2
src/views/warningHome/index.vue

@@ -220,8 +220,8 @@ onMounted(() => {
 });
 
 onUnmounted(() => {
-    console.log('deeddesss');
-    warningMap.destroyMap()
+    alarmLayer.removeAllLayers()
+    // warningMap.destroyMap()
 })
 
 // ai与地图交互

+ 8 - 0
src/views/warningHome/map/alarmLayer.js

@@ -186,6 +186,14 @@ class AlarmLayer {
             this.kmap.map.getView().setCenter([113.6805952006568, 23.60747406160339])
         }
     }
+
+    // 销毁地图图层
+    removeAllLayers() {
+        this.warningLayer && this.kmap.map.removeLayer(this.warningLayer.layer)
+        this.plantLayer && this.kmap.map.removeLayer(this.plantLayer.layer)
+        this.warningLayer = null
+        this.plantLayer = null
+    }
 }
 
 export default AlarmLayer;