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/leafletDraw.vue |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/components/leafletDraw.vue b/src/components/leafletDraw.vue
index 971b16f..7f9b5e1 100644
--- a/src/components/leafletDraw.vue
+++ b/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,"*")
+
             })
         },
 

--
Gitblit v1.9.3