Browse Source

修复初始化地图加载 无法绘画小班边界bug

wangcc 2 years ago
parent
commit
18c27ff904
1 changed files with 18 additions and 5 deletions
  1. 18 5
      src/components/amapnow.vue

+ 18 - 5
src/components/amapnow.vue

@@ -432,7 +432,7 @@ export default {
   mounted() {
     this.initAMap();
     // 加载小班边界
-    this.getSmallClass();
+    // this.getSmallClass();
   },
   methods: {
     ...mapMutations([
@@ -659,6 +659,8 @@ export default {
     },
     //绘制某个区域的边界
     renderAreaPolygons(areaNode) {
+      // 加载小班边界
+      this.getSmallClass();
       let _this = this;
       //更新地图视野
       if (this.$store.state.addr.mapLevel != 'street') {
@@ -981,9 +983,11 @@ export default {
         pageNum: 0,
         pageSize: 25
       };
+      console.log(that.leftPage);
       let mapLevel = that.$store.state.addr.mapLevel;
       let res = await smallClassMap({ ...params, ...pageData });
-      if (res.code == 200) {
+      console.log(res.rows);
+      if (res.code == 200 && res.total > 25) {
         const total = res.total;
         const totalPage = Math.ceil(total / pageData.pageSize);
         const render = (page, mapLevel) => {
@@ -994,8 +998,8 @@ export default {
             smallClassMap({ ...params, ...pageData }).then((response) => {
               if (response.code == 200) {
                 response.rows.forEach((item) => {
-                  if (item.smallId != null) {
-                  }
+                  // if (item.smallId != null) {
+                  // }
                   // this.smallClassMapArr.push(item);
                   if (that.leftPage === 'forest') {
                     this.addForestPolygon(item);
@@ -1008,6 +1012,14 @@ export default {
           });
         };
         render(pageData.pageNum, mapLevel);
+      } else {
+        res.rows.forEach((item) => {
+          if (that.leftPage === 'forest') {
+            this.addForestPolygon(item);
+          } else if (this.leftPage === 'treeSpecies') {
+            this.addTreeSpeciesPolygon(item);
+          }
+        });
       }
     },
     mapPolygon() {
@@ -1038,6 +1050,7 @@ export default {
     addForestPolygon(item) {
       let that = this;
       if (item) {
+        // console.log(item);
         // smallClassMapArr.forEach((item) => {
         let polyData = JSON.parse(item.mapInfo);
         for (let elementLs in polyData.features) {
@@ -1431,7 +1444,7 @@ export default {
           } else if (item.eventType == 3) {
             item.eventContLabel = '病虫害';
             baseIcon = insectpestIcon;
-          }else if (item.eventType == 4) {
+          } else if (item.eventType == 4) {
             item.eventContLabel = '偷盗林木';
             baseIcon = cutTreeIcon;
           }