From 642169a0f3836dfcbecd1a4c5953160d4e316934 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Tue, 11 Jul 2023 15:30:43 +0800
Subject: [PATCH] 首页加载面数据更改

---
 src/utils/turfPolygon.js |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/utils/turfPolygon.js b/src/utils/turfPolygon.js
index aab3663..b0a3ea6 100644
--- a/src/utils/turfPolygon.js
+++ b/src/utils/turfPolygon.js
@@ -2,7 +2,7 @@
  * @Author: shuishen 1109946754@qq.com
  * @Date: 2023-03-31 10:52:25
  * @LastEditors: shuishen 1109946754@qq.com
- * @LastEditTime: 2023-07-07 14:34:41
+ * @LastEditTime: 2023-07-11 15:30:20
  * @FilePath: \srs-police-affairs\src\utils\turfPolygon.js
  * @Description:
  *
@@ -37,9 +37,16 @@
   let arr = [];
 
   params.forEach((areaArray) => {
-    JSON.parse(areaArray).coordinates.forEach((item) => {
-      arr.push(turf.centroid(turf.polygon([item[0]])).geometry.coordinates);
-    });
+    let data = JSON.parse(areaArray);
+    if (data.type == "Polygon") {
+      data.coordinates.forEach((item) => {
+        arr.push(turf.centroid(turf.polygon([item])).geometry.coordinates);
+      });
+    } else {
+      data.coordinates.forEach((item) => {
+        arr.push(turf.centroid(turf.polygon([item[0]])).geometry.coordinates);
+      });
+    }
   });
 
   if (arr.length == 1) {

--
Gitblit v1.9.3