wangcc 2 роки тому
батько
коміт
42a6d60fdb
1 змінених файлів з 26 додано та 17 видалено
  1. 26 17
      src/components/amapPow.vue

+ 26 - 17
src/components/amapPow.vue

@@ -2,8 +2,8 @@
  * @Description: 
  * @Author: wangcc
  * @Date: 2022-10-19 09:32:46
- * @LastEditors: wangcc 1053578651@qq.com
- * @LastEditTime: 2022-11-06 20:02:33
+ * @LastEditors: wangcc
+ * @LastEditTime: 2022-11-09 17:54:57
  * @FilePath: \castgroup_bigscreen\src\components\amapPow.vue
  * @Copyright: Copyright (c) 2016~2022 by wangcc, All Rights Reserved. 
 -->
@@ -696,7 +696,7 @@ export default {
         this.$store.state.addr.mapLevel == 'street' ||
         this.$store.state.addr.mapLevel == 'district'
       ) {
-        this.map.setFitView(this.smallMarker, false, false, 14);
+        this.map.setFitView(this.smallMarker, false, false, 12);
       }
       this.smallMarkers.push(_this.smallMarker);
       this.smallMarker.on('click', (e) => {
@@ -962,8 +962,11 @@ export default {
       // this.getSmallClass();
       let _this = this;
       //更新地图视野
-      if (this.$store.state.addr.mapLevel != 'street') {
+      if (this.$store.state.addr.mapLevel == 'city' ||
+              this.$store.state.addr.mapLevel == 'province') {
         this.map.setBounds(areaNode.getBounds(), null, null, false);
+      }else{
+        this.map.setFitView(this.smallMarker, false, false, 14);
       }
       // 加载相关标识
       this.mapPolygon();
@@ -1263,7 +1266,7 @@ export default {
 
         this.boundaryPolygon.on('click', (e) => {
           let centerLanLatArr = [e.lnglat.lng, e.lnglat.lat];
-          that.map.remove(that.townPolygons);
+          // that.map.remove(that.townPolygons);
           // that.districtExplorer.clearFeaturePolygons();
           let valCode = element.properties.XIANG;
           let areaId = '';
@@ -1284,14 +1287,14 @@ export default {
             name: label,
             mapLevel: 'street'
           });
-          let townPolygon = new AMap.Polygon({
-            map: that.map,
-            path: element.geometry.coordinates,
-            strokeColor: 'yellow',
-            strokeWeight: 3,
-            fillOpacity: 0
-          });
-          this.townPolygonArr.push(townPolygon);
+          // let townPolygon = new AMap.Polygon({
+          //   map: that.map,
+          //   path: element.geometry.coordinates,
+          //   strokeColor: 'yellow',
+          //   strokeWeight: 3,
+          //   fillOpacity: 0
+          // });
+          // this.townPolygonArr.push(townPolygon);
           that.map.setZoomAndCenter(14, centerLanLatArr, false, 13);
         });
         that.boundaryPolygon.on('rightclick', function (e) {
@@ -1760,15 +1763,21 @@ export default {
             content: treeSmallLabel //设置文本标注内容
           });
           that.treeCompMarkers.push(that.smallMarker);
+          if (
+            this.$store.state.addr.mapLevel == 'street' ||
+            this.$store.state.addr.mapLevel == 'district'
+          ) {
+            this.map.setFitView(this.smallMarker, false, false, 14);
+          }
           // });
-          that.smallMarker.on('click',(e)=>{
+          that.smallMarker.on('click', (e) => {
             if (that.treesPolygonArr) {
-              that.map.remove(that.treesPolygonArr)
+              that.map.remove(that.treesPolygonArr);
             }
             if (that.treeCompMarkers) {
-              that.map.remove(that.treeCompMarkers)
+              that.map.remove(that.treeCompMarkers);
             }
-          })
+          });
           that.map.on('rightclick', function (e) {
             if (that.treeCompMarkers) {
               that.map.remove(that.treeCompMarkers);