From c054c78741b02a6dd103080c1c801600dbcd3caa Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sat, 03 Sep 2022 11:41:39 +0800
Subject: [PATCH] 完成绘图后给后台返回数据
---
src/components/revampDraw.vue | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/src/components/revampDraw.vue b/src/components/revampDraw.vue
index 861142d..ace5b24 100644
--- a/src/components/revampDraw.vue
+++ b/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,"*")
})
},
--
Gitblit v1.9.3