Jelajahi Sumber

优化小班边界预加载

wangcc 3 tahun lalu
induk
melakukan
a3d0b37973
1 mengubah file dengan 20 tambahan dan 5 penghapusan
  1. 20 5
      src/components/amap.vue

+ 20 - 5
src/components/amap.vue

@@ -138,6 +138,7 @@ export default {
         }
         if (this.parentId) {
           this.getSmallClass();
+          this.mapPolygon();
           this.switch2AreaNode(
             this.parentId,
             this.$store.state.addr.mapLevel,
@@ -247,8 +248,8 @@ export default {
             } else if (val.eventType == 3) {
               val.eventContLabel = '病虫害';
               baseIcon = insectpestIcon;
-            }else if(val.eventType == 4) {
-              val.eventContLabel = '偷盗林木'
+            } else if (val.eventType == 4) {
+              val.eventContLabel = '偷盗林木';
             }
             let treeSmallLabel =
               "<div class='info-small'>" +
@@ -285,7 +286,7 @@ export default {
               content: treeSmallLabel //设置文本标注内容
             });
             this.map.add(this.eventMarker);
-          }else if(val.name == false && this.eventMarker) {
+          } else if (val.name == false && this.eventMarker) {
             this.map.remove(this.eventMarker);
           }
         }
@@ -572,6 +573,7 @@ export default {
       //更新地图视野
       this.map.setBounds(areaNode.getBounds(), null, null, false);
       this.getSmallClass();
+      this.mapPolygon();
       //清除已有的绘制内容
       this.districtExplorer.clearFeaturePolygons();
       //绘制子区域
@@ -656,7 +658,20 @@ export default {
         townId: this.$store.state.addr.selectStreet.areaId
       };
       smallClassMap(params).then((res) => {
-        this.smallClassMapArr = res.rows;
+        if (res.code == 200) {
+          this.smallClassMapArr = res.rows;
+          if (this.leftPage === 'forest') {
+            this.addForestPolygon(this.smallClassMapArr);
+          } else if (this.leftPage === 'treeSpecies') {
+            this.addTreeSpeciesPolygon();
+          } else if (this.leftPage === 'economics') {
+            this.getEconomics(this.smallClassMapArr);
+          }
+        }
+      });
+    },
+    mapPolygon() {
+      if (this.smallClassMapArr) {
         if (this.leftPage === 'forest') {
           this.addForestPolygon(this.smallClassMapArr);
           this.getForestSample(this.leftPage);
@@ -668,7 +683,7 @@ export default {
         } else if (this.leftPage === 'event') {
           this.getEven();
         }
-      });
+      }
     },
     addForestPolygon(smallClassMapArr) {
       let that = this;