修复 保存点 偏移

This commit is contained in:
mmc
2026-03-11 08:59:33 +08:00
parent 302f37e100
commit 591af2959c

View File

@@ -498,8 +498,14 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
.toList(),
),
'outer': jsonEncode(
gcjOuterPoints.map((point) {
final wgs84 = gcj02ToWgs84(point.latitude, point.longitude);
// 核心修改:根据机器人模式选择不同的坐标源
(_currentRobotMode == RobotMode.robot ? _robotModeWgsPoints : gcjOuterPoints).map((point) {
// Robot模式:_robotModeWgsPoints本身就是WGS84坐标,无需转换
// Point模式:gcjOuterPoints是GCJ02坐标,需要转换为WGS84
final wgs84 = _currentRobotMode == RobotMode.robot
? point // Robot模式直接使用原始WGS84坐标
: gcj02ToWgs84(point.latitude, point.longitude); // Point模式转换
return {'lng': wgs84.longitude, 'lat': wgs84.latitude};
}).toList(),
),
@@ -557,6 +563,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
_markedPoints.clear(); // 清空打点
gcjPathPoints.clear(); // 清空路径
gcjOuterPoints.clear(); // 清空外边界
_robotModeWgsPoints.clear();
_isPanelOpen = false; // 关闭操作面板
_isWorkAreaCompleted = false; // 重置作业区域完成状态
@@ -631,7 +638,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 1. 作业区域模式:清空作业点 + 重置路径
if (_currentAreaMode == AreaMode.work) {
if (_currentRobotMode == RobotMode.robot) {
_robotModeWgsPoints.clear();
_markedPoints.clear();
ToastUtils.showSuccess(context, '已清空所有作业点');
} else {
@@ -645,6 +651,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
_markedPoints.clear();
gcjPathPoints.clear();
gcjOuterPoints.clear();
_robotModeWgsPoints.clear();
_isWorkAreaCompleted = false;
_saveBoxOpen = false;
typedPathList.clear();
@@ -701,9 +708,9 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 清空打点和轨迹数据
_markedPoints.clear();
gcjPathPoints.clear();
_robotModeWgsPoints.clear();
_robotModeObsWgsPoints.clear();
gcjOuterPoints.clear();
_robotModeWgsPoints.clear();
_isWorkAreaCompleted = false;
_saveBoxOpen = false;