From 00b89e4c17c3d34301be0bd51604b0c29ed77c3a Mon Sep 17 00:00:00 2001
From: seatonwan9 <seatonwan9@163.com>
Date: 星期五, 28 五月 2021 09:27:17 +0800
Subject: [PATCH] 修改风险统计图加载

---
 src/components/LayerController/logic/EnvironmentRisk.js |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/src/components/LayerController/logic/EnvironmentRisk.js b/src/components/LayerController/logic/EnvironmentRisk.js
index 65591ac..e7478e7 100644
--- a/src/components/LayerController/logic/EnvironmentRisk.js
+++ b/src/components/LayerController/logic/EnvironmentRisk.js
@@ -1,7 +1,7 @@
 /**
  * 鐜椋庨櫓
  */
-// const EnvironmentRiskIndex = require('@components/BaseNav/').default
+// const EnvironmentRiskIndex = require('@components/base-page/').default
 
 // 璇锋眰鎺ュ彛鏁版嵁
 const mapApi = require('../../../api/mapApi').default
@@ -11,6 +11,8 @@
 const echarts = require('echarts/lib/echarts')
 
 module.exports = function () {
+  // 瀛樻斁鐜舰鍥剧殑鏁扮粍
+  let riskLayerGroup = []
   /**
    * 杩斿洖marker瀵硅薄鏁扮粍
    * @param L leaflet瀵硅薄
@@ -20,6 +22,11 @@
       L: L,
       layer: layer
     })
+    layer.addLayer(riskLayerGroup)
+  }
+
+  this.start = async () => {
+    riskLayerGroup = window.layerFactory.L.featureGroup().addTo(window.layerFactory.map)
     const result = await mapApi.getRiskEnterprise()
     const features = result.features
     for (var i = 0; i < features.length; i++) {
@@ -33,25 +40,30 @@
       if (distract !== '闀挎睙娌跨嚎') {
         continue
       }
-      const bgMarker = L.marker([coordinates[1], coordinates[0]], {
-        icon: L.divIcon({
+      window.layerFactory.L.marker([coordinates[1], coordinates[0]], {
+        icon: this.animalService.L.divIcon({
           className: '',
           iconAnchor: [15, 45],
           iconSize: [40, 40],
           html: '<div style="width: 40px; height: 40px; background-color: rgba(255,255,255,1); position: relative; border-radius: 50%;"></div>'
         })
-      })
-      layer.addLayer(bgMarker)
-      const chartMarker = L.marker([coordinates[1], coordinates[0]], {
-        icon: L.divIcon({
+      }).addTo(riskLayerGroup)
+      // this.animalService.layer.addLayer(bgMarker)
+      window.layerFactory.L.marker([coordinates[1], coordinates[0]], {
+        icon: this.animalService.L.divIcon({
           className: '',
           iconAnchor: [30, 60],
           iconSize: [70, 70],
           html: '<div id="qy_id_' + qyId + '" style="width: 70px; height: 70px; background-color: transparent; position: relative; border-radius: 50%;"></div>'
         })
-      })
-      layer.addLayer(chartMarker)
+      }).addTo(riskLayerGroup)
       chartRender(properties)
+    }
+  }
+
+  this.destory = () => {
+    if (riskLayerGroup) {
+      riskLayerGroup.remove()
     }
   }
 
@@ -61,7 +73,6 @@
    * @returns {string}
    */
   this.bindTooltip = (layer) => {
-
   }
 
   /**
@@ -69,9 +80,12 @@
    * @param e
    */
   this.clickListener = (e) => {
-
   }
 
+  /**
+   * 鐜舰楗煎浘
+   * @param properties
+   */
   function chartRender (properties) {
     const qyId = properties.QY_ID
     const qyjc = properties.QY_JC
@@ -98,7 +112,7 @@
         {
           type: 'text',
           left: 'center',
-          top: '35%',
+          top: '43%', // 璁剧疆鐜舰鏂囧瓧鐨則op浣嶇疆
           style: {
             text: num,
             textAlign: 'center',

--
Gitblit v1.8.0