Browse Source

视图优化

wangcc 2 years ago
parent
commit
c55d3f8c13
4 changed files with 21 additions and 10 deletions
  1. 16 7
      src/components/amapPow.vue
  2. 3 1
      src/components/pickerAddr.vue
  3. 1 1
      src/store/addr/index.js
  4. 1 1
      src/views/index.vue

+ 16 - 7
src/components/amapPow.vue

@@ -3,7 +3,7 @@
  * @Author: wangcc
  * @Date: 2022-10-19 09:32:46
  * @LastEditors: wangcc
- * @LastEditTime: 2022-11-11 14:01:26
+ * @LastEditTime: 2022-11-11 14:48:00
  * @FilePath: \castgroup_bigscreen\src\components\amapPow.vue
  * @Copyright: Copyright (c) 2016~2022 by wangcc, All Rights Reserved. 
 -->
@@ -120,9 +120,7 @@ export default {
         // 加载小班边界
         // this.getSmallClass();
         this.parentId = val;
-        if (this.projectSmallClassArr) {
-          this.map.remove(this.projectSmallClassArr);
-        }
+
         if (this.$store.state.addr.mapLevel == 'street') {
           this.parentId = val.substring(0, 6);
           if (this.map) {
@@ -134,6 +132,11 @@ export default {
             );
           }
         }
+        if (this.$store.state.addr.mapLevel == 'province') {
+          if (this.projectSmallClassArr) {
+            this.map.remove(this.projectSmallClassArr);
+          }
+        }
         if (this.$store.state.addr.mapLevel != 'street') {
           this.selectData = this.$store.state.addr.selectCity;
           this.districtData = this.$store.state.addr.selectDistrict;
@@ -257,7 +260,9 @@ export default {
             this.setMapLabel(val);
             if (
               this.$store.state.addr.mapLevel == 'province' ||
-              this.$store.state.addr.mapLevel == 'city' ||(this.$store.state.addr.mapLevel == 'district'&& this.$store.state.addr.selectCity.prop == '1')
+              this.$store.state.addr.mapLevel == 'city' ||
+              (this.$store.state.addr.mapLevel == 'district' &&
+                this.$store.state.addr.selectCity.prop == '1')
             ) {
               if (val.countyCode) {
                 // this.switch2AreaNode(val.countyCode.substring(0, 6));
@@ -471,6 +476,7 @@ export default {
             this.map.remove(this.projectSmallClassArr);
           }
           let capitals = { animations: 'scaless' };
+          let lngLagArr = [];
           val.forEach((element) => {
             let lnglat = new AMap.LngLat(element.longitude, element.latitude);
             var projectSmallClass = new AMap.Text({
@@ -500,7 +506,9 @@ export default {
               position: lnglat
             });
             this.projectSmallClassArr.push(projectSmallClass);
-
+            if (this.$store.state.addr.mapLevel == 'district') {
+            this.map.setFitView(projectSmallClass, false, false, 12);
+          }
             projectSmallClass.on('click', (e) => {
               if (_this.projectPolygonArr) {
                 _this.map.remove(_this.projectPolygonArr);
@@ -553,6 +561,7 @@ export default {
               });
             });
           });
+          
         }
       }
     }
@@ -974,7 +983,7 @@ export default {
         this.$store.state.addr.mapLevel != 'province'
       ) {
         this.map.setFitView(this.smallMarker, false, false, 14);
-      } 
+      }
       // 加载相关标识
       this.mapPolygon();
       //清除已有的绘制内容

+ 3 - 1
src/components/pickerAddr.vue

@@ -127,7 +127,8 @@ export default {
     ...mapMutations([
       'changeSelectCity',
       'changeSelectDistrict',
-      'changeSelectStreet'
+      'changeSelectStreet',
+      'changeSelectProject'
     ]),
     // getCityChange() {
     //   if (this.areaData.cityId && this.areaData.cityName) {
@@ -208,6 +209,7 @@ export default {
       this.changeSelectCity({});
       this.changeSelectDistrict({});
       this.changeSelectStreet({});
+      this.changeSelectProject({});
     }
   }
 };

+ 1 - 1
src/store/addr/index.js

@@ -127,7 +127,7 @@ const addr = {
     // 获取省市县
     searchArea({ commit }, params = {}) {
       console.log("searchArea", params);
-      commit("changeSelectProject", {});//去掉选择的项目
+      // commit("changeSelectProject", {});//去掉选择的项目
       searchApi({ parentId: params.parentId }).then(res => {
         console.log(params.parentId);
         if (params.mapLevel == "city") {

+ 1 - 1
src/views/index.vue

@@ -3,7 +3,7 @@
  * @Author: wangcc
  * @Date: 2022-07-06 15:56:45
  * @LastEditors: wangcc
- * @LastEditTime: 2022-11-11 14:01:54
+ * @LastEditTime: 2022-11-11 14:31:09
  * @FilePath: \castgroup_bigscreen\src\views\index.vue
  * @Copyright: Copyright (c) 2016~2022 by wangcc, All Rights Reserved. 
 -->