| | |
| | | |
| | | imgUrl: "", |
| | | file: "", |
| | | regionFull: false |
| | | regionFull: false, |
| | | tempBounds:"" |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | |
| | | 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('&') |
| | |
| | | let area = this.$turf.area(this.$turf.polygon([arr])) |
| | | |
| | | window.parent.postMessage(area,"*") |
| | | |
| | | this.map.flyToBounds(this.rectangleLayer.getBounds()); |
| | | |
| | | }) |
| | | }, |
| | |
| | | |
| | | imgUrl: "", |
| | | file: "", |
| | | regionFull: false |
| | | regionFull: false, |
| | | tempBounds:"" |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | // 添加顶点 |
| | | console.log(e, '添加顶点') |
| | | }) |
| | | |
| | | // this.map.flyToBounds(this.rectangleLayer.getBounds()); |
| | | |
| | | }, |
| | | |
| | | addPolygon (position) { |
| | |
| | | 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.polygonLayer){//编辑层 |
| | | if(this.polygonLayer.getBounds() != this.tempBounds){ |
| | | if(this.map.getZoom()>16){ |
| | | this.polygonLayer.getBounds()._northEast.lng = this.polygonLayer.getBounds()._northEast.lng+0.007 |
| | | this.tempBounds = this.polygonLayer.getBounds() |
| | | this.map.flyToBounds(this.polygonLayer.getBounds(),{maxZoom:18}); |
| | | }else{ |
| | | this.polygonLayer.getBounds()._northEast.lng = this.polygonLayer.getBounds()._northEast.lng+0.06 |
| | | this.tempBounds = this.polygonLayer.getBounds() |
| | | this.map.flyToBounds(this.polygonLayer.getBounds(),{maxZoom:22}); |
| | | } |
| | | window.parent.postMessage(obj,"*") |
| | | }) |
| | | .catch(function (error) { |
| | | console.error('oops, something went wrong!', error) |
| | | }) |
| | | } |
| | | }else{ |
| | | if(this.rectangleLayer.getBounds() != this.tempBounds){ |
| | | if(this.map.getZoom()>16){ |
| | | this.rectangleLayer.getBounds()._northEast.lng = this.rectangleLayer.getBounds()._northEast.lng+0.009 |
| | | 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:20}); |
| | | } |
| | | } |
| | | } |
| | | }else{//小程序镜头移动 |
| | | if(this.polygonLayer){ |
| | | //移动编辑层镜头到中心 |
| | | this.map.flyToBounds(this.polygonLayer.getBounds(),{maxZoom:18}); |
| | | }else{ |
| | | this.map.flyToBounds(this.rectangleLayer.getBounds(),{maxZoom:18}); |
| | | } |
| | | } |
| | | |
| | | return |
| | | setTimeout(() => { |
| | | if(parmasObj.status){//后台截图 |
| | | domtoimage.toPng(document.getElementById('map'), { width: 450, height: 450 }) |
| | | .then( (dataUrl) => { |
| | | |
| | | }else{//小程序截图 |
| | | var base64Image = dataUrl // 后台返回的base64数据 |
| | | var imgData = base64Image.replace(/[\r\n]/g, '') // 将回车换行换为空字符'' |
| | | |
| | | domtoimage.toPng(document.getElementById('map'), { width: 375, height: 750 }) |
| | | .then( (dataUrl) => { |
| | | |
| | | 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() |
| | | return |
| | | |
| | | |
| | | }else{//小程序截图 |
| | | |
| | | }) |
| | | .catch(function (error) { |
| | | console.error('oops, something went wrong!', error) |
| | | }) |
| | | } |
| | | 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) |
| | | }) |
| | | } |
| | | }, 1100); |
| | | |
| | | |
| | | |
| | | |
| | | // domtoimage.toPng(document.getElementById('map'), { width: 375, height: 750 }) |
| | |
| | | let area = this.$turf.area(this.$turf.polygon([arr])) |
| | | window.parent.postMessage(area,"*") |
| | | |
| | | this.map.flyToBounds(this.rectangleLayer.getBounds()); |
| | | // this.map.flyToBounds(this.rectangleLayer.getBounds()); |
| | | }) |
| | | }, |
| | | |