From 1767c2c878ec1892ae560f81b32b5afdd2ceebfd Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 27 Sep 2022 16:32:03 +0800
Subject: [PATCH] 小程序地图模式根据农场变化坐标

---
 src/components/leafletDraw.vue |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/src/components/leafletDraw.vue b/src/components/leafletDraw.vue
index f05694b..362032a 100644
--- a/src/components/leafletDraw.vue
+++ b/src/components/leafletDraw.vue
@@ -2,7 +2,7 @@
     <div ref="imageWrapper">
         <div class="btn-grounp">
             <button v-if="addShow" class="draw" @click="draw()">开始绘制</button>
-            <button v-if="!addShow" class="repeal" @click="repeal()">撤销</button>
+            <button v-if="!addShow&&repealShow" class="repeal" @click="repeal()">撤销</button>
             <button v-if="regionFull" class="save" @click="save()">保存</button>
         </div>
         <!-- <button class="disDraw" @click="disDraw()">关闭绘制</button> -->
@@ -24,6 +24,7 @@
             lng: "",
             lat: "",
             addShow: false,
+            repealShow:false,
 
             currentPolygons: [],
 
@@ -109,11 +110,11 @@
                 doubleClickZoom: false, // 禁用双击放大
                 attributionControl: false, // 移除右下角leaflet标识
             })
-            this.$L.tileLayer('http://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0', {
+            this.$L.tileLayer('https://t{s}.tianditu.gov.cn/DataServer?T=img_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0', {
                 subdomains: [0, 1, 2, 3, 4, 5, 6, 7],
             }).addTo(this.map)
 
-            this.$L.tileLayer('http://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0', {
+            this.$L.tileLayer('https://t{s}.tianditu.gov.cn/DataServer?T=cva_w&x={x}&y={y}&l={z}&tk=e9533f5acb2ac470b07f406a4d24b4f0', {
                 subdomains: [0, 1, 2, 3, 4, 5, 6, 7],
             }).addTo(this.map)
 
@@ -146,7 +147,7 @@
             this.complete.remove()
 
             this.addShow = true
-
+            this.repealShow = false
             this.regionFull = false
 
             // Object.values(this.map._layers).forEach(item => {
@@ -197,6 +198,8 @@
             var parmasObj = this.getUrlParams(str)
 
             if(parmasObj.status){//后台镜头移动
+                this.repealShow = false
+                this.regionFull = false
                 if(this.rectangleLayer.getBounds() != this.tempBounds){
                     if(this.map.getZoom()>16){
                         this.rectangleLayer.getBounds()._northEast.lng = this.rectangleLayer.getBounds()._northEast.lng+0.007
@@ -231,6 +234,10 @@
                         console.error('oops, something went wrong!', error)
                     }) 
                     
+                    setTimeout(() => {
+                        this.repealShow = true
+                        this.regionFull = true
+                    }, 1000);
 
                 }else{//小程序截图
                     domtoimage.toPng(document.getElementById('map'), { width: 375, height: 600 })
@@ -246,7 +253,7 @@
                         console.error('oops, something went wrong!', error)
                     }) 
                 }   
-            }, 1500);
+            }, 1000);
         },
 
         getUrlParams(urlParams) {
@@ -274,7 +281,7 @@
             this.map.on('pm:drawstart', ({ workingLayer }) => {
 
                 this.addShow = false
-
+                this.repealShow = false
                 that.rectangleLayer = workingLayer
 
                 console.log(workingLayer, 5465456)
@@ -291,7 +298,7 @@
             })
 
             this.map.on("pm:create", e => {
-
+                that.repealShow = true
                 that.regionFull = true
 
                 // 绘制坐标
@@ -391,9 +398,11 @@
     .repeal {
         // width: 100px;
         // height: 44px;
+
         border-radius: 22px;
         border: none;
-
+        color: #000;
+        background: #fff;
         width: 150px;
         height: 66px;
         font-size: 30px;
@@ -405,7 +414,8 @@
         // height: 44px;
         border-radius: 22px;
         border: none;
-
+        color: #000;
+        background: #fff;
         width: 150px;
         height: 66px;
         font-size: 30px;

--
Gitblit v1.9.3