From b781d8f13a5b6ce20cfad7ec6c2d0a72013a8764 Mon Sep 17 00:00:00 2001
From: 徐旺旺 <11530253@qq.com>
Date: 星期三, 21 四月 2021 16:51:43 +0800
Subject: [PATCH] 修改比例尺的BUG

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

diff --git a/src/components/LayerController/service/WfsLayerService.js b/src/components/LayerController/service/WfsLayerService.js
index cb0a4bf..0c601a2 100644
--- a/src/components/LayerController/service/WfsLayerService.js
+++ b/src/components/LayerController/service/WfsLayerService.js
@@ -35,48 +35,50 @@
   }
 
   draw (features) {
-    const icon = this.config.icon
-    const styles = this.config.styles
-    Object.assign(STYLES, styles)
-    const geojsonLayer = this.L.geoJSON(features, {
-      style: function (feature) {
-        return {
-          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) => {
-        return this.L.canvasMarker(latlng,
-          {
-            img: {
-              // url: 'assets/images/map/marker-icon.png',
-              url: '/assets/images/map/' + icon,
-              size: STYLES.ICON_SIZE
-            }
+    if (features && features.length > 0) {
+      const icon = this.config.icon
+      const styles = this.config.styles
+      Object.assign(STYLES, styles)
+      const geojsonLayer = this.L.geoJSON(features, {
+        style: function (feature) {
+          return {
+            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) => {
+          return this.L.canvasMarker(latlng,
+            {
+              img: {
+                // url: 'assets/images/map/marker-icon.png',
+                url: '/assets/images/map/' + icon,
+                size: STYLES.ICON_SIZE
+              }
+            })
+        },
+        onEachFeature: (feature, layer) => {
+          layer.bindPopup((layer) => {
+            this.popupComp.setDatas(layer)
+            this.popupComp.setShow()
+            return this.popupComp.$el
+          }, {
+            className: 's-map-popup',
+            minWidth: 300,
+            closeButton: false,
+            autoClose: false
           })
-      },
-      onEachFeature: (feature, layer) => {
-        layer.bindPopup((layer) => {
-          this.popupComp.setDatas(layer)
-          this.popupComp.setShow()
-          return this.popupComp.$el
-        }, {
-          className: 's-map-popup',
-          minWidth: 300,
-          closeButton: false,
-          autoClose: false
-        })
-          .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(this.layer)
-    setZIndex(geojsonLayer)
+            .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(this.layer)
+      setZIndex(geojsonLayer)
+    }
   }
 
   mouseOverListener (e, layer) {

--
Gitblit v1.8.0