diff --git a/lib/features/home/presentation/widgets/map/testmap_pages.dart b/lib/features/home/presentation/widgets/map/testmap_pages.dart index b6713378..f0ece73a 100644 --- a/lib/features/home/presentation/widgets/map/testmap_pages.dart +++ b/lib/features/home/presentation/widgets/map/testmap_pages.dart @@ -498,8 +498,14 @@ class _MapPageEnterpriseState extends State { .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 { _markedPoints.clear(); // 清空打点 gcjPathPoints.clear(); // 清空路径 gcjOuterPoints.clear(); // 清空外边界 + _robotModeWgsPoints.clear(); _isPanelOpen = false; // 关闭操作面板 _isWorkAreaCompleted = false; // 重置作业区域完成状态 @@ -631,7 +638,6 @@ class _MapPageEnterpriseState extends State { // 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 { _markedPoints.clear(); gcjPathPoints.clear(); gcjOuterPoints.clear(); + _robotModeWgsPoints.clear(); _isWorkAreaCompleted = false; _saveBoxOpen = false; typedPathList.clear(); @@ -701,9 +708,9 @@ class _MapPageEnterpriseState extends State { // 清空打点和轨迹数据 _markedPoints.clear(); gcjPathPoints.clear(); - _robotModeWgsPoints.clear(); _robotModeObsWgsPoints.clear(); gcjOuterPoints.clear(); + _robotModeWgsPoints.clear(); _isWorkAreaCompleted = false; _saveBoxOpen = false;