wangcc 2 lat temu
rodzic
commit
615dec252e
1 zmienionych plików z 21 dodań i 12 usunięć
  1. 21 12
      src/components/amapnow.vue

+ 21 - 12
src/components/amapnow.vue

@@ -83,6 +83,7 @@ export default {
       // 林木结构小班边界
       treesPolygonArr: [],
       townPolygonArr: [],
+      economicsArr: [],
       selectData: {},
       districtData: {},
       streetData: {}
@@ -91,6 +92,8 @@ export default {
   watch: {
     '$store.state.addr.parentId': {
       handler(val) {
+        // 加载小班边界
+        this.getSmallClass();
         this.parentId = val;
         if (this.$store.state.addr.mapLevel == 'street') {
           this.parentId = val.substring(0, 6);
@@ -139,14 +142,6 @@ export default {
       if (val.label && val.value && val.areaId) {
         this.map.remove(this.polygon);
         let labelTown = val.label;
-        // switch (val.label) {
-        //   case '定威水族乡':
-        //     labelTown = '定威乡'
-        //     break;
-
-        //   default:
-        //     break;
-        // }
         this.map.setCity(labelTown);
         if (this.leftPage === 'forest') {
           this.addForestPolygon(this.smallClassMapArr);
@@ -475,9 +470,6 @@ export default {
           version: '1.1',
           plugins: ['overlay/SimpleMarker']
         },
-        Loca: {
-          version: '2.0'
-        },
         features: ['road', 'bg', 'building']
       }).then((AMap) => {
         _this.AMap = AMap;
@@ -487,7 +479,8 @@ export default {
           center: _this.lngLat,
           pitch: 45,
           terrain: true,
-          features: ['road', 'bg', 'building']
+          features: ['road', 'bg', 'building'],
+          layers: [new AMap.TileLayer.Satellite()]
         });
         AMapUI.load(
           ['ui/geo/DistrictExplorer', 'ui/geo/DistrictCluster', 'lib/$'],
@@ -843,6 +836,10 @@ export default {
     },
     // 加载林场
     setMarker() {
+      this.forestFarmData = [];
+      if (this.treesMarkerArr.length > 0) {
+        this.map.remove(this.treesMarkerArr);
+      }
       farmInfo().then((res) => {
         this.forestFarmData = res.rows;
         let parentMarker = require('@/assets/img/pre-marker.png');
@@ -967,12 +964,23 @@ export default {
       });
     },
     getSmallClass() {
+      this.smallClassMapArr = [];
       let params = {
         cityId: this.$store.state.addr.selectCity.areaId,
         countyId: this.$store.state.addr.selectDistrict.areaId
         // townId: this.$store.state.addr.selectStreet.areaId
       };
+      if (this.smallClassPolygonArr.length > 0) {
+        this.map.remove(this.smallClassPolygonArr);
+      }
+      if (this.treesPolygonArr.length > 0) {
+        this.map.remove(this.treesPolygonArr);
+      }
+      if (this.economicsArr.length > 0) {
+        this.map.remove(this.economicsArr);
+      }
       smallClassMap(params).then((res) => {
+        console.log(res);
         if (res.code == 200) {
           this.smallClassMapArr = res.rows;
           if (this.leftPage === 'forest') {
@@ -1485,6 +1493,7 @@ export default {
             zIndex: 999,
             cursor: 'pointer'
           });
+          this.economicsArr.push(polygon);
           polygon.on('mouseover', (e) => {
             polygon.setOptions({
               fillOpacity: 0.7,