From 7af28eaca09c2aa1f9a678df081abb378e22ee16 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期三, 10 三月 2021 10:12:17 +0800
Subject: [PATCH] 菜单组件联动

---
 src/components/helpers/ServiceLayerHelper.js |   27 +++++++++++++++++----------
 1 files changed, 17 insertions(+), 10 deletions(-)

diff --git a/src/components/helpers/ServiceLayerHelper.js b/src/components/helpers/ServiceLayerHelper.js
index 96da67f..567be72 100644
--- a/src/components/helpers/ServiceLayerHelper.js
+++ b/src/components/helpers/ServiceLayerHelper.js
@@ -126,10 +126,8 @@
       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
-        }
+        var layer = that.loadGeojson(res.data, item)
+        that.layerArray[code] = layer
       }
     } else {
       that.layerArray[code].addTo(that.map)
@@ -143,7 +141,8 @@
   loadGeojson (res, opt) {
     var that = this
     var icon = opt.icon
-    const layergroup = that.L.featureGroup().addTo(that.map)
+    const featureGroup = that.L.featureGroup()
+    const featureList = []
     const geojson = that.L.geoJSON(res.features, {
       style: function (feature) {
         return {
@@ -152,9 +151,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) {
@@ -166,6 +165,12 @@
               size: styles.defaultLineStyle.size
             }
           })
+      },
+      onEachFeature: function (feature, layer) {
+        console.log(feature)
+        console.log(layer)
+        featureList.push(layer)
+        layer.addTo(featureGroup)
       }
     }).bindPopup(function (layer) {
       that.popupComp.setDatas(layer)
@@ -220,14 +225,16 @@
           })
         }
       // }).addTo(that.map)
-      }).addTo(layergroup)
+      // }).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 geojson
+    featureGroup.addTo(that.map)
+    return featureGroup
   }
 
   removeLayer (item) {

--
Gitblit v1.8.0