From 05e440319ddbb5090836f5742c7ca80cc763d5c3 Mon Sep 17 00:00:00 2001
From: ywb <347742090@qq.com>
Date: Tue, 26 May 2026 16:07:44 +0800
Subject: [PATCH] =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=9D=90=E6=A0=87=E8=BD=AC?=
=?UTF-8?q?=E6=8D=A2?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
agv_app/static/js/setting.js | 15 +++++++++++++--
agv_app/templates/setting.html | 2 +-
2 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/agv_app/static/js/setting.js b/agv_app/static/js/setting.js
index 9829fcd..8aa06c7 100644
--- a/agv_app/static/js/setting.js
+++ b/agv_app/static/js/setting.js
@@ -180,8 +180,19 @@ createApp({
return
}
const rect = e.target.getBoundingClientRect()
- const px = (e.clientX - rect.left) / rect.width
- const py = (e.clientY - rect.top) / rect.height
+ let px = (e.clientX - rect.left) / rect.width
+ let py = (e.clientY - rect.top) / rect.height
+ // 逆旋转补偿:地图 CSS transform: rotate() 后,点击坐标需反向旋转
+ // 使同一物理点在不同旋转角度下返回相同的世界坐标
+ const rotation = (this.mapRotation || 0) * Math.PI / 180
+ if (rotation !== 0) {
+ const cx = px - 0.5
+ const cy = py - 0.5
+ const cos = Math.cos(-rotation)
+ const sin = Math.sin(-rotation)
+ px = cx * cos - cy * sin + 0.5
+ py = cx * sin + cy * cos + 0.5
+ }
const { resolution, origin } = this.mapMeta
const wx = origin[0] + px * resolution * this.mapMeta.width
const wy = origin[1] + (1 - py) * resolution * this.mapMeta.height
diff --git a/agv_app/templates/setting.html b/agv_app/templates/setting.html
index 5ec3a8c..907f3f5 100644
--- a/agv_app/templates/setting.html
+++ b/agv_app/templates/setting.html
@@ -582,6 +582,6 @@
-
+