From f9d3a259d075beffd21abfdc58345ff8588f3c2d Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Tue, 06 Sep 2022 15:10:31 +0800
Subject: [PATCH] 后台完成绘图后位移
---
src/components/leafletDraw.vue | 83 ++++++++++++++++++++++++-----------------
1 files changed, 48 insertions(+), 35 deletions(-)
diff --git a/src/components/leafletDraw.vue b/src/components/leafletDraw.vue
index 116c71a..f05694b 100644
--- a/src/components/leafletDraw.vue
+++ b/src/components/leafletDraw.vue
@@ -33,7 +33,8 @@
imgUrl: "",
file: "",
- regionFull: false
+ regionFull: false,
+ tempBounds:""
}
},
created () {
@@ -194,46 +195,60 @@
var str = window.location.search.substring(1)
var parmasObj = this.getUrlParams(str)
- if(parmasObj.status){//后台截图
- domtoimage.toPng(document.getElementById('map'), { width: 970, height: 400 })
- .then( (dataUrl) => {
- var base64Image = dataUrl // 后台返回的base64数据
- var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符''
-
- var obj = {
- url:imgData,
- polygons:arr,
- area:area
+ if(parmasObj.status){//后台镜头移动
+ if(this.rectangleLayer.getBounds() != this.tempBounds){
+ if(this.map.getZoom()>16){
+ this.rectangleLayer.getBounds()._northEast.lng = this.rectangleLayer.getBounds()._northEast.lng+0.007
+ this.tempBounds = this.rectangleLayer.getBounds()
+ this.map.flyToBounds(this.rectangleLayer.getBounds(),{maxZoom:18});
+ }else{
+ this.rectangleLayer.getBounds()._northEast.lng = this.rectangleLayer.getBounds()._northEast.lng+0.06
+ this.tempBounds = this.rectangleLayer.getBounds()
+ this.map.flyToBounds(this.rectangleLayer.getBounds(),{maxZoom:18});
}
- window.parent.postMessage(obj,"*")
- })
- .catch(function (error) {
- console.error('oops, something went wrong!', error)
- })
+ }
+ }else{//小程序镜头移动
+ this.map.flyToBounds(this.rectangleLayer.getBounds(),{maxZoom:18});
+ }
+ setTimeout(() => {
+ if(parmasObj.status){//后台截图
+ domtoimage.toPng(document.getElementById('map'), { width: 450, height: 450 })
+ .then( (dataUrl) => {
- }else{//小程序截图
- domtoimage.toPng(document.getElementById('map'), { width: 375, height: 750 })
- .then( (dataUrl) => {
+ var base64Image = dataUrl // 后台返回的base64数据
+ var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符''
- var base64Image = dataUrl // 后台返回的base64数据
- var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符''
- wx.miniProgram.postMessage({
- data: { polygons: arr, area, bgUrl: imgData },
+ var obj = {
+ url:imgData,
+ polygons:arr,
+ area:area
+ }
+ window.parent.postMessage(obj,"*")
})
+ .catch(function (error) {
+ console.error('oops, something went wrong!', error)
+ })
+
- wx.miniProgram.navigateBack()
-
-
-
- })
- .catch(function (error) {
- console.error('oops, something went wrong!', error)
- })
- }
-
+ }else{//小程序截图
+ domtoimage.toPng(document.getElementById('map'), { width: 375, height: 600 })
+ .then( (dataUrl) => {
+ var base64Image = dataUrl // 后台返回的base64数据
+ var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符''
+ wx.miniProgram.postMessage({
+ data: { polygons: arr, area, bgUrl: imgData },
+ })
+ wx.miniProgram.navigateBack()
+ })
+ .catch(function (error) {
+ console.error('oops, something went wrong!', error)
+ })
+ }
+ }, 1500);
},
+
getUrlParams(urlParams) {
var obj = {}
var arrList = urlParams.split('&')
@@ -314,8 +329,6 @@
let area = this.$turf.area(this.$turf.polygon([arr]))
window.parent.postMessage(area,"*")
-
- this.map.flyToBounds(this.rectangleLayer.getBounds());
})
},
--
Gitblit v1.9.3