From 9cb8b56e0b8e4c09dec23a88fb1591e3135c73ef Mon Sep 17 00:00:00 2001 From: yyy <2605810609@qq.com> Date: Fri, 14 Mar 2025 10:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E7=9B=B4=E7=BA=BF=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=8C=89=E7=85=A7sortNum=E6=9C=80=E5=A4=A7=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/mapPage/realTimeMap/editMap.vue | 24 +++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/views/mapPage/realTimeMap/editMap.vue b/src/views/mapPage/realTimeMap/editMap.vue index 77949a51..620993cb 100644 --- a/src/views/mapPage/realTimeMap/editMap.vue +++ b/src/views/mapPage/realTimeMap/editMap.vue @@ -2029,16 +2029,28 @@ const clickDrawSelectionArea = () => { //将一个数组中的点位 按照第一个和最后一个排成一条直线 const mapPointsToLine = (points) => { // 找出 locationX 最大和最小的项 + // let minXPoint = points[0] + // let maxXPoint = points[0] + // points.forEach((point) => { + // if (point.locationX < minXPoint.locationX) { + // minXPoint = point + // } + // if (point.locationX > maxXPoint.locationX) { + // maxXPoint = point + // } + // }) + + // 找出sortNum最小和最大的点 let minXPoint = points[0] let maxXPoint = points[0] - points.forEach((point) => { - if (point.locationX < minXPoint.locationX) { - minXPoint = point + for (let i = 1; i < points.length; i++) { + if (points[i].sortNum < minXPoint.sortNum) { + minXPoint = points[i] } - if (point.locationX > maxXPoint.locationX) { - maxXPoint = point + if (points[i].sortNum > maxXPoint.sortNum) { + maxXPoint = points[i] } - }) + } const dx = maxXPoint.locationX - minXPoint.locationX const dy = maxXPoint.locationY - minXPoint.locationY