From 564d0ab88c6ddf0b3d56a9eeba5ee72d6fff01b9 Mon Sep 17 00:00:00 2001
From: wangqi <magical1908@outlook.com>
Date: 星期三, 07 四月 2021 15:33:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/develop' into develop

---
 src/components/LayerController/service/WfsLayerService.js |   41 ++++++++++++++++++++++++-----------------
 1 files changed, 24 insertions(+), 17 deletions(-)

diff --git a/src/components/LayerController/service/WfsLayerService.js b/src/components/LayerController/service/WfsLayerService.js
index e5a175d..3aae541 100644
--- a/src/components/LayerController/service/WfsLayerService.js
+++ b/src/components/LayerController/service/WfsLayerService.js
@@ -2,7 +2,7 @@
  * 鍔犺浇涓氬姟鏁版嵁鍥惧眰
  */
 
-import styles from '../../../conf/Styles'
+import { STYLES } from '../../../conf/Constants'
 import AjaxUtils from '../../../utils/AjaxUtils'
 
 class WfsLayerService {
@@ -21,25 +21,33 @@
   }
 
   init (layer) {
+    this.layer = layer
     const wfsUrl = this.config.wfs
     if (wfsUrl) {
-      AjaxUtils.get4JsonDataByUrl(wfsUrl, this.params, (res) => this.draw(layer, res.data.features))
+      this.loadData(wfsUrl)
     }
   }
 
-  draw (layer, features) {
+  loadData (wfsUrl) {
+    AjaxUtils.get4JsonDataByUrl(wfsUrl, this.params, (res) => {
+      console.log(res)
+      this.draw(res.data.features)
+    })
+  }
+
+  draw (features) {
     const icon = this.config.icon
-    const geojson = this.L.geoJSON(features, {
+    this.L.geoJSON(features, {
       style: function (feature) {
         return {
-          fill: styles.defaultLineStyle.fill,
-          weight: styles.defaultLineStyle.weight,
-          fillColor: styles.defaultLineStyle.fillColor,
-          color: styles.defaultLineStyle.color,
-          fillOpacity: styles.defaultLineStyle.fillOpacity,
-          opacity: styles.defaultLineStyle.opacity,
-          dashArray: styles.defaultLineStyle.dashArray,
-          dashSpeed: styles.defaultLineStyle.dashSpeed
+          fill: STYLES.FILL,
+          weight: STYLES.WEIGHT,
+          fillColor: STYLES.FILL_COLOR,
+          color: STYLES.COLOR,
+          fillOpacity: STYLES.FILL_OPACITY,
+          opacity: STYLES.OPACITY,
+          dashArray: STYLES.DASH_ARRAY,
+          dashSpeed: STYLES.DASH_SPPED
         }
       },
       pointToLayer: (geoJsonPoint, latlng) => {
@@ -48,7 +56,7 @@
             img: {
               // url: 'assets/images/map/marker-icon.png',
               url: '/assets/images/map/' + icon,
-              size: styles.defaultLineStyle.size
+              size: STYLES.ICON_SIZE
             }
           })
       },
@@ -66,8 +74,7 @@
           .bindTooltip((layer) => this.tooltipListener(layer), { direction: 'bottom', offset: [0, 15], sticky: true })
           .on('mouseover', (e) => this.mouseOverListener(e, layer)).on('mouseout', (e) => this.mouseOutListener(e, layer))
       }
-    }).addTo(layer)
-    return geojson
+    }).addTo(this.layer)
   }
 
   mouseOverListener (e, layer) {
@@ -90,13 +97,13 @@
     const icon = this.config.icon
     const type = e.target.feature.geometry.type
     if (type === 'LineString' || type === 'MultiLineString') {
-      layer.setStyle({ weight: styles.defaultLineStyle.weight, color: styles.defaultLineStyle.color })
+      layer.setStyle({ weight: STYLES.WEIGHT, color: STYLES.COLOR })
     }
     if (type === 'Point' || type === 'MultiPoint') {
       layer.setStyle({
         img: {
           url: '/assets/images/map/' + icon,
-          size: styles.defaultLineStyle.size
+          size: STYLES.ICON_SIZE
         }
       })
     }

--
Gitblit v1.8.0