diff --git a/lib/features/home/presentation/widgets/map/testmap_pages.dart b/lib/features/home/presentation/widgets/map/testmap_pages.dart index 11a8ade8..e2b94e68 100644 --- a/lib/features/home/presentation/widgets/map/testmap_pages.dart +++ b/lib/features/home/presentation/widgets/map/testmap_pages.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:collection'; import 'dart:convert'; import 'dart:math'; import 'dart:math' as math; @@ -143,9 +144,6 @@ class _MapPageEnterpriseState extends State { setState(() { _mapCenter = highPrecisionCenter; }); - - // 可选:打印验证精度(保留15位小数) - debugPrint('地图中心更新(高精度):纬度=${_mapCenter.latitude.toStringAsFixed(15)}, 经度=${_mapCenter.longitude.toStringAsFixed(15)}'); } } }); @@ -983,13 +981,27 @@ class _MapPageEnterpriseState extends State { } /// 开始作业 - void _startWork() { + void _startWork() async { if (gcjPathPoints.isEmpty) return; setState(() { _workStatus = WorkStatus.working; }); + // 步骤1:将 List 转换为 List + final List pathModels = gcjPathPoints.map((latLng) { + return work_area_model.DeviceAddPathPointModel( + latitude: latLng.latitude, // 纬度 + longitude: latLng.longitude, // 经度 + ); + }).toList(); + + // 步骤2:将 List 转换为 Queue(队列) + final Queue pathQueue = Queue.from(pathModels); + + // 步骤3:调用 Cubit 方法(类型匹配) + await context.read().startRoutePlanning(pathQueue); + debugPrint('开始作业:${_selectedPlot!.plotName},路径数据:$gcjPathPoints'); // 可选:显示作业提示 @@ -997,22 +1009,21 @@ class _MapPageEnterpriseState extends State { } /// 暂停作业 - void _pauseWork() { + void _pauseWork() async { setState(() { _workStatus = WorkStatus.paused; }); + await context.read().pauseRoutePlanning(); // 模拟暂停逻辑(替换为你的实际暂停代码) debugPrint('暂停作业:${_selectedPlot!.plotName}'); - - // 可选:显示暂停提示 - ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('作业已暂停'), backgroundColor: Colors.amber)); } - void _stopWork() { + void _stopWork() async { setState(() { _workStatus = WorkStatus.idle; }); + await context.read().stopRoutePlanning(); // 模拟停止逻辑(替换为你的实际停止代码) debugPrint('停止作业:${_selectedPlot!.plotName}'); // 可选:显示停止提示 @@ -1020,10 +1031,11 @@ class _MapPageEnterpriseState extends State { } /// 继续作业 - void _resumeWork() { + void _resumeWork() async { setState(() { _workStatus = WorkStatus.working; }); + await context.read().resumeRoutePlanning(); } void _showDeleteConfirmDialog(PlotData plot, Function(PlotData) onDelete) {