From 0b0b09ff2285abf99e41d822d2b5c6f0ca0ee239 Mon Sep 17 00:00:00 2001
From: YANGDL <114714267@qq.com>
Date: 星期三, 10 三月 2021 10:17:51 +0800
Subject: [PATCH] 修复ie下不能显示的问题

---
 src/components/helpers/ServiceLayerHelper.js |   45 +++++++++++++++++++++++++++++++++------------
 1 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js
index 3e22efe..8d1ab87 100644
--- a/src/components/helpers/ServiceLayerHelper.js
+++ b/src/components/helpers/ServiceLayerHelper.js
@@ -25,7 +25,18 @@
   }
 
   getByLayerId (layerId) {
-
+    for (var k in this.layerArray) {
+      var layer = this.layerArray[k]
+      var geojson = layer.toGeoJSON()
+      var features = geojson.features
+      for (var j = 0; j < features.length; j++) {
+        var feature = features[j]
+        if (feature.id === layerId) {
+          return layer
+        }
+      }
+    }
+    return null
   }
 
   initDisplayZoom (layerConfig) {
@@ -105,18 +116,21 @@
      * @param url
      * @param item
      */
-  loadGeojsonLayer (url, item) {
+  async loadGeojsonLayer (url, item) {
     var matches = this.regex.exec(url)
     var matchValue = item[matches[1]]
     var code = item.code
     var newUrl = url.replace(this.regex, matchValue)
     var that = this
     if (!that.layerArray[code]) {
-      AjaxUtils.GetDataAsynByUrl(newUrl, {}, function (res) {
-        store.commit('addSewersDatas', res)
-        var layer = that.loadGeojson(res, item)
-        that.layerArray[code] = layer
-      })
+      const res = await AjaxUtils.GetDataAsynByUrl(newUrl, {})
+      if (res.data instanceof Object && Object.prototype.hasOwnProperty.call(res.data, 'features')) {
+        store.commit('addSewersDatas', res.data)
+        if (newUrl.indexOf('绠$綉') !== -1 || newUrl.indexOf('鍥涢��') !== -1) {
+          var layer = that.loadGeojson(res.data, item)
+          that.layerArray[code] = layer
+        }
+      }
     } else {
       that.layerArray[code].addTo(that.map)
     }
@@ -130,6 +144,7 @@
     var that = this
     var icon = opt.icon
     const featureGroup = that.L.featureGroup().addTo(that.map)
+    const featureList = []
     const geojson = that.L.geoJSON(res.features, {
       style: function (feature) {
         return {
@@ -138,9 +153,9 @@
           fillColor: styles.defaultLineStyle.fillColor,
           color: styles.defaultLineStyle.color,
           fillOpacity: styles.defaultLineStyle.fillOpacity,
-          opacity: styles.defaultLineStyle.opacity
-          // dashArray: styles.defaultLineStyle.dashArray,
-          // dashSpeed: styles.defaultLineStyle.dashSpeed
+          opacity: styles.defaultLineStyle.opacity,
+          dashArray: styles.defaultLineStyle.dashArray,
+          dashSpeed: styles.defaultLineStyle.dashSpeed
         }
       },
       pointToLayer: function (geoJsonPoint, latlng) {
@@ -152,6 +167,10 @@
               size: styles.defaultLineStyle.size
             }
           })
+      },
+      onEachFeature: function (feature, layer) {
+        featureList.push(layer)
+        layer.addTo(featureGroup)
       }
     }).bindPopup(function (layer) {
       that.popupComp.setDatas(layer)
@@ -205,14 +224,16 @@
             }
           })
         }
-      }).addTo(featureGroup)
+      // }).addTo(that.map)
+      // }).addTo(featureGroup)
+      })
     store.commit('addSewersDatas', geojson)
     if (Object.prototype.hasOwnProperty.call(res, 'features') && res.features.length > 0 && (res.features[0].geometry.type === 'LineString' || res.features[0].geometry.type === 'MultiLineString')) {
       geojson.bringToBack()
     } else {
       geojson.bringToFront()
     }
-    return featureGroup
+    return geojson
   }
 
   removeLayer (item) {

--
Gitblit v1.8.0