From 0547901378595158423e4f992ad889abe9d0aad0 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期一, 19 四月 2021 14:03:11 +0800
Subject: [PATCH] 修复图层重复加载、图层动画颜色不一致、地图数据缺失问题

---
 src/components/LayerController/service/LayerFactory.js |   30 ++++++++++++++++++++++++++----
 1 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/src/components/LayerController/service/LayerFactory.js b/src/components/LayerController/service/LayerFactory.js
index d475fb6..9b05042 100644
--- a/src/components/LayerController/service/LayerFactory.js
+++ b/src/components/LayerController/service/LayerFactory.js
@@ -2,7 +2,7 @@
 import BusiLayerService from './BusiLayerService'
 import WmsLayerService from './WmsLayerService'
 import EventLayerService from './EventLayerService'
-
+import { clone } from '../../../utils/utils'
 class LayerFactory {
   constructor (options) {
     this.L = options.L
@@ -112,15 +112,37 @@
   hide (config) {
     var layer = this.layers[config.code]
     layer && this.map.removeLayer(layer)
-    this.load(config)
+    // this.load(config)
   }
 
   toggle (code) {
 
   }
 
-  flyByLayerId (code, id) {
-    const layer = this.layers[code]
+  /**
+   *
+   * 鏍规嵁浼犵殑 feature瀵硅薄瀹氫綅
+   * @param code
+   * @param feature
+   */
+  flyByFeature (feature, code) {
+    const type = feature.geometry.type
+    var point = []
+    switch (type) {
+      case 'Point':
+        point = clone(feature.geometry.coordinates)
+        break
+      case 'MultiLineString':
+        var coordinates = feature.geometry.coordinates
+        point = clone(coordinates[parseInt(coordinates.length / 2)][0])
+        break
+    }
+    window.map.flyTo(point.reverse(), 15)
+    code && this.openPopup(code, feature.id)
+  }
+
+  openPopup (layerId, id) {
+    const layer = this.layers[layerId]
 
     if (layer.eachLayer) {
       layer.eachLayer(function (layer) {

--
Gitblit v1.8.0