智慧农业绘制地图
guoshilong
2022-09-03 c054c78741b02a6dd103080c1c801600dbcd3caa
完成绘图后给后台返回数据
2 files modified
40 ■■■■■ changed files
src/components/leafletDraw.vue 15 ●●●●● patch | view | raw | blame | history
src/components/revampDraw.vue 25 ●●●●● patch | view | raw | blame | history
src/components/leafletDraw.vue
@@ -188,7 +188,7 @@
            var str = window.location.search.substring(1)
            var parmasObj = this.getUrlParams(str)
            if(parmasObj.status!=""){//后台截图
            if(parmasObj.status){//后台截图
                domtoimage.toPng(document.getElementById('map'), { width: 970, height: 400 })
                .then( (dataUrl) => {
@@ -296,6 +296,19 @@
                e.layer.on('pm:vertexadded', e => {
                    console.log(e, "添加顶点")
                })
                var arr = []
                this.polygons.forEach(item => {
                    arr.push([item.lng, item.lat])
                })
                arr.push([this.polygons[0].lng, this.polygons[0].lat])
                let area = this.$turf.area(this.$turf.polygon([arr]))
                window.parent.postMessage(area,"*")
            })
        },
src/components/revampDraw.vue
@@ -141,6 +141,20 @@
            this.polygonLayer.on('pm:edit', e => {
                // 拖动后的坐标
                that.polygons = e.target._latlngs[0]
            var arr = []
            this.polygons.forEach(item => {
                arr.push([item.lng, item.lat])
            })
            arr.push([this.polygons[0].lng, this.polygons[0].lat])
            let area = this.$turf.area(this.$turf.polygon([arr]))
            window.parent.postMessage(area,"*")
            })
            this.polygonLayer.on('pm:vertexadded', e => {
                // 添加顶点
@@ -436,6 +450,17 @@
                e.layer.on('pm:vertexadded', e => {
                    console.log(e, "添加顶点")
                })
                var arr = []
                this.polygons.forEach(item => {
                    arr.push([item.lng, item.lat])
                })
                arr.push([this.polygons[0].lng, this.polygons[0].lat])
                let area = this.$turf.area(this.$turf.polygon([arr]))
                window.parent.postMessage(area,"*")
            })
        },