From bbce81a396e22743b1fbf0c54fed05ab79c99e72 Mon Sep 17 00:00:00 2001
From: 陈泽平 <chenzeping>
Date: 星期六, 29 五月 2021 16:28:51 +0800
Subject: [PATCH] Merge branch 'develop' of http://xearth.cn:6600/r/wuyushui/SewerAndRainNetwork into develop

---
 src/components/LayerController/logic/EnvironmentRisk.js |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/src/components/LayerController/logic/EnvironmentRisk.js b/src/components/LayerController/logic/EnvironmentRisk.js
index e7478e7..677e670 100644
--- a/src/components/LayerController/logic/EnvironmentRisk.js
+++ b/src/components/LayerController/logic/EnvironmentRisk.js
@@ -1,8 +1,6 @@
 /**
- * 鐜椋庨櫓
+ * 鐜椋庨櫓缁熻鍥�
  */
-// const EnvironmentRiskIndex = require('@components/base-page/').default
-
 // 璇锋眰鎺ュ彛鏁版嵁
 const mapApi = require('../../../api/mapApi').default
 // 浣跨敤灏佽鏂规硶
@@ -11,10 +9,11 @@
 const echarts = require('echarts/lib/echarts')
 
 module.exports = function () {
-  // 瀛樻斁鐜舰鍥剧殑鏁扮粍
-  let riskLayerGroup = []
+  // 鐜舰缁熻鍥炬暟缁�
+  let riskLayerGroup = null
+
   /**
-   * 杩斿洖marker瀵硅薄鏁扮粍
+   * 鍒濆鍖栧浘灞傛暟缁�
    * @param L leaflet瀵硅薄
    */
   this.init = async (layer, L) => {
@@ -22,25 +21,31 @@
       L: L,
       layer: layer
     })
-    layer.addLayer(riskLayerGroup)
   }
 
+  /**
+   * 鍔犺浇鍥惧眰
+   * @returns {Promise<void>}
+   */
   this.start = async () => {
-    riskLayerGroup = window.layerFactory.L.featureGroup().addTo(window.layerFactory.map)
-    const result = await mapApi.getRiskEnterprise()
+    if (riskLayerGroup) { // 鍥惧眰鍏ㄩ�夋椂锛屾竻鐞嗗浘灞傛暟缁勫苟閲嶆柊鍔犺浇
+      riskLayerGroup.remove()
+      riskLayerGroup = null
+    }
+    riskLayerGroup = this.animalService.L.featureGroup().addTo(this.animalService.layer)
+    const result = await mapApi.getEnvironmentRisk()
     const features = result.features
-    for (var i = 0; i < features.length; i++) {
+    for (let i = 0; i < features.length; i++) {
       const feature = features[i]
       const geometry = feature.geometry
       const properties = feature.properties
       const qyId = properties.QY_ID
-      // const qyJc = properties.QY_JC
       const distract = properties.DISTRACT
       const coordinates = geometry.coordinates
       if (distract !== '闀挎睙娌跨嚎') {
         continue
       }
-      window.layerFactory.L.marker([coordinates[1], coordinates[0]], {
+      this.animalService.L.marker([coordinates[1], coordinates[0]], {
         icon: this.animalService.L.divIcon({
           className: '',
           iconAnchor: [15, 45],
@@ -48,8 +53,7 @@
           html: '<div style="width: 40px; height: 40px; background-color: rgba(255,255,255,1); position: relative; border-radius: 50%;"></div>'
         })
       }).addTo(riskLayerGroup)
-      // this.animalService.layer.addLayer(bgMarker)
-      window.layerFactory.L.marker([coordinates[1], coordinates[0]], {
+      this.animalService.L.marker([coordinates[1], coordinates[0]], {
         icon: this.animalService.L.divIcon({
           className: '',
           iconAnchor: [30, 60],
@@ -61,35 +65,23 @@
     }
   }
 
+  /**
+   * 娓呴櫎鍥惧眰
+   */
   this.destory = () => {
     if (riskLayerGroup) {
       riskLayerGroup.remove()
+      riskLayerGroup = null
     }
   }
 
   /**
-   * tips
-   * @param layer
-   * @returns {string}
-   */
-  this.bindTooltip = (layer) => {
-  }
-
-  /**
-   * 鐐瑰嚮寮圭獥
-   * @param e
-   */
-  this.clickListener = (e) => {
-  }
-
-  /**
-   * 鐜舰楗煎浘
+   * Echarts鐜舰楗煎浘
    * @param properties
    */
   function chartRender (properties) {
     const qyId = properties.QY_ID
     const qyjc = properties.QY_JC
-    // const qyQc = properties.QY_QC
     const num = properties.QY_NUM
     const oneLevel = properties.QY_ONELEVEL
     const twoLevel = properties.QY_TWOLEVEL
@@ -150,8 +142,5 @@
       }]
     }
     o.setOption(option)
-    /* o.on('click', function (params) {
-        map.flyTo(L.latLng([params.data.y, params.data.x]), 15)
-    }) */
   }
 }

--
Gitblit v1.8.0