Explorar el Código

地图缩小返回上一层

wangcc hace 2 años
padre
commit
9f82abe243
Se han modificado 2 ficheros con 26 adiciones y 13 borrados
  1. 26 11
      src/components/amap.vue
  2. 0 2
      src/components/pickerAddr.vue

+ 26 - 11
src/components/amap.vue

@@ -97,10 +97,13 @@ export default {
         }
       }
     },
+    '$store.state.addr.selectStreet'(val) {
+      console.log(val);
+      // this.putPolygon(val)
+    },
     '$store.state.addr.page': {
       handler(val) {
         this.leftPage = val;
-        console.losmallClassMapArr(this.parentId);
         if (this.parentId) {
           // this.getrjx()
           this.switch2AreaNode(
@@ -357,8 +360,6 @@ export default {
         var zoom = this.map.getZoom(); //获取当前地图级别
         console.log(zoom);
         if (zoom > '11.8' && zoom < '12.1') {
-          console.log('开始检测');
-          console.log(this.districtData);
           let districtCode = this.districtData.value.substring(0, 6);
           this.$store.dispatch('searchArea', {
             parentId: districtCode,
@@ -366,6 +367,21 @@ export default {
             mapLevel: 'district'
           });
         }
+        if (zoom > '9' && zoom < '9.2') {
+          let districtCode = this.selectData.value.substring(0, 6);
+          this.$store.dispatch('searchArea', {
+            parentId: districtCode,
+            name: this.selectData.label,
+            mapLevel: 'city'
+          });
+        }
+        if (zoom > '7.6' && zoom < '7.9') {
+          this.$store.dispatch('searchArea', {
+            parentId: '520000',
+            name: '贵州省',
+            mapLevel: 'province'
+          });
+        }
       });
       that.getDistrict(adName, mapLevel);
       this.switch2AreaNode(adcode);
@@ -1020,21 +1036,20 @@ export default {
     getrjx(adcode, selectStreet) {
       if (adcode == '522632') {
         axios.get('/static/rongjangintown.json').then((res) => {
-          let putPolygonData = [];
-          putPolygonData = res.data.features;
-          this.putPolygon(putPolygonData, selectStreet);
+          this.putPolygonData = res.data.features;
+          this.putPolygon();
         });
       } else if (adcode == '520181') {
         axios.get('/static/qingzhenzhen.json').then((res) => {
-          let qingzhenputPolygonData = [];
-          qingzhenputPolygonData = res.data.features;
-          this.putPolygon(qingzhenputPolygonData, selectStreet);
+          this.putPolygonData = res.data.features;
+          this.putPolygon();
         });
       }
     },
-    putPolygon(putPolygonData, selectStreet) {
+    putPolygon(selectStreet) {
       let that = this;
-      putPolygonData.forEach((element) => {
+      console.log(selectStreet);
+      this.putPolygonData.forEach((element) => {
         this.boundaryPolygon = new AMap.Polygon({
           map: that.map,
           path: element.geometry.coordinates,

+ 0 - 2
src/components/pickerAddr.vue

@@ -187,7 +187,6 @@ export default {
         });
         
       }
-      if (level != 'street') {
         this.parentId = val.value.substring(0, 6);
         this.name = level;
         this.$store.dispatch('searchArea', {
@@ -195,7 +194,6 @@ export default {
           name: val.label,
           mapLevel: level
         });
-      }
     },
     provinceClick() {
       // console.log('provinceClick','provinceClick');