| | |
| | | <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> --> |
| | |
| | | lng: "", |
| | | lat: "", |
| | | addShow: false, |
| | | repealShow:false, |
| | | |
| | | currentPolygons: [], |
| | | |
| | |
| | | |
| | | imgUrl: "", |
| | | file: "", |
| | | regionFull: false |
| | | regionFull: false, |
| | | tempBounds:"" |
| | | } |
| | | }, |
| | | created () { |
| | |
| | | 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) |
| | | |
| | |
| | | this.complete.remove() |
| | | |
| | | this.addShow = true |
| | | |
| | | this.repealShow = false |
| | | this.regionFull = false |
| | | |
| | | // Object.values(this.map._layers).forEach(item => { |
| | |
| | | |
| | | 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){//后台镜头移动 |
| | | 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 |
| | | 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) |
| | | }) |
| | | |
| | | setTimeout(() => { |
| | | this.repealShow = true |
| | | this.regionFull = true |
| | | }, 1000); |
| | | |
| | | 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) |
| | | }) |
| | | } |
| | | }, 1000); |
| | | }, |
| | | |
| | | getUrlParams(urlParams) { |
| | | var obj = {} |
| | | var arrList = urlParams.split('&') |
| | |
| | | this.map.on('pm:drawstart', ({ workingLayer }) => { |
| | | |
| | | this.addShow = false |
| | | |
| | | this.repealShow = false |
| | | that.rectangleLayer = workingLayer |
| | | |
| | | console.log(workingLayer, 5465456) |
| | |
| | | }) |
| | | |
| | | this.map.on("pm:create", e => { |
| | | |
| | | that.repealShow = true |
| | | that.regionFull = true |
| | | |
| | | // 绘制坐标 |
| | |
| | | let area = this.$turf.area(this.$turf.polygon([arr])) |
| | | |
| | | window.parent.postMessage(area,"*") |
| | | |
| | | this.map.flyToBounds(this.rectangleLayer.getBounds()); |
| | | |
| | | }) |
| | | }, |
| | |
| | | .repeal { |
| | | // width: 100px; |
| | | // height: 44px; |
| | | |
| | | border-radius: 22px; |
| | | border: none; |
| | | |
| | | color: #000; |
| | | background: #fff; |
| | | width: 150px; |
| | | height: 66px; |
| | | font-size: 30px; |
| | |
| | | // height: 44px; |
| | | border-radius: 22px; |
| | | border: none; |
| | | |
| | | color: #000; |
| | | background: #fff; |
| | | width: 150px; |
| | | height: 66px; |
| | | font-size: 30px; |