diff --git a/lib/features/home/presentation/widgets/map/testmap_pages.dart b/lib/features/home/presentation/widgets/map/testmap_pages.dart index a9eb1910..11636aaa 100644 --- a/lib/features/home/presentation/widgets/map/testmap_pages.dart +++ b/lib/features/home/presentation/widgets/map/testmap_pages.dart @@ -339,16 +339,12 @@ class _MapPageEnterpriseState extends State { ) .toList(), ), + 'outer': jsonEncode( - _markedPoints - .map( - (point) => { - // 外边界点数组 - 'lng': point.longitude, - 'lat': point.latitude, - }, - ) - .toList(), + gcjOuterPoints.map((point) { + final wgs84 = gcj02ToWgs84(point.latitude, point.longitude); + return {'lng': wgs84.longitude, 'lat': wgs84.latitude}; + }).toList(), ), 'planModel': _currentWorkMode == WorkMode.bow ? 0 : 2, // 作业模式值 }; @@ -429,6 +425,9 @@ class _MapPageEnterpriseState extends State { setState(() { _markedPoints.clear(); // 清空打点 gcjPathPoints.clear(); // 清空路径 + gcjOuterPoints.clear(); // 清空外边界 + + _isPanelOpen = false; // 关闭操作面板 }); ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text('地块「$plotName」保存成功!'), backgroundColor: Colors.green)); @@ -825,6 +824,7 @@ class _MapPageEnterpriseState extends State { _selectedPlot = plot; _isListBoxOpen = false; _isWorkPanelOpen = true; + _isPanelOpen = false; // 关闭操作面板,专注作业界面 }); // 移动地图到中心 List allPoints = []; @@ -843,6 +843,7 @@ class _MapPageEnterpriseState extends State { _selectedPlot = plot; _isListBoxOpen = false; _isWorkPanelOpen = true; + _isPanelOpen = false; // 关闭操作面板,专注作业界面 }); } } else { @@ -852,6 +853,7 @@ class _MapPageEnterpriseState extends State { _selectedPlot = plot; _isListBoxOpen = false; _isWorkPanelOpen = true; + _isPanelOpen = false; // 关闭操作面板,专注作业界面 }); } } else { @@ -1317,6 +1319,7 @@ class _MapPageEnterpriseState extends State { }).toList(); gcjOuterPoints = List.from(_markedPoints); + _markedPoints.clear(); }); moveMapToPointsCenter(gcjPathPoints); } diff --git a/lib/features/home/presentation/widgets/startpoint_area.dart b/lib/features/home/presentation/widgets/startpoint_area.dart index 058aef28..9095cf0f 100644 --- a/lib/features/home/presentation/widgets/startpoint_area.dart +++ b/lib/features/home/presentation/widgets/startpoint_area.dart @@ -80,10 +80,7 @@ class _BottomOperationPanelState extends State { _buildTabContent(), // 底部标签页切换(修复背景色切换+状态更新) Container( - decoration: BoxDecoration( - color: Colors.grey[200], - borderRadius: BorderRadius.circular(8), - ), + decoration: BoxDecoration(color: Colors.grey[200], borderRadius: BorderRadius.circular(8)), child: Row( children: [ Expanded( @@ -98,20 +95,9 @@ class _BottomOperationPanelState extends State { child: Container( padding: const EdgeInsets.symmetric(vertical: 10), // 选中地块时背景为白色,否则透明 - decoration: BoxDecoration( - color: _currentTab == '地块' - ? Colors.white - : Colors.transparent, - borderRadius: BorderRadius.circular(8), - ), + decoration: BoxDecoration(color: _currentTab == '地块' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)), child: const Center( - child: Text( - '地块', - style: TextStyle( - color: Colors.black87, - fontSize: 16, - ), - ), + child: Text('地块', style: TextStyle(color: Colors.black87, fontSize: 16)), ), ), ), @@ -128,20 +114,9 @@ class _BottomOperationPanelState extends State { child: Container( padding: const EdgeInsets.symmetric(vertical: 10), // 选中航线时背景为白色,否则透明 - decoration: BoxDecoration( - color: _currentTab == '航线' - ? Colors.white - : Colors.transparent, - borderRadius: BorderRadius.circular(8), - ), + decoration: BoxDecoration(color: _currentTab == '航线' ? Colors.white : Colors.transparent, borderRadius: BorderRadius.circular(8)), child: const Center( - child: Text( - '航线', - style: TextStyle( - color: Colors.black87, - fontSize: 16, - ), - ), + child: Text('航线', style: TextStyle(color: Colors.black87, fontSize: 16)), ), ), ), @@ -168,7 +143,7 @@ class _BottomOperationPanelState extends State { DropdownButton( value: _robotMode, items: const [ - DropdownMenuItem(value: RobotMode.point, child: Text("地图打点")), + DropdownMenuItem(value: RobotMode.point, child: Text("十字准星")), DropdownMenuItem(value: RobotMode.robot, child: Text("机器人模式")), ], onChanged: (v) { @@ -187,10 +162,7 @@ class _BottomOperationPanelState extends State { child: Container( width: 40, height: 40, - decoration: const BoxDecoration( - color: Color(0xFF00C853), - shape: BoxShape.circle, - ), + decoration: const BoxDecoration(color: Color(0xFF00C853), shape: BoxShape.circle), child: const Icon(Icons.add, color: Colors.white, size: 32), ), ), @@ -246,10 +218,7 @@ class _BottomOperationPanelState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( - '作业行距(米)', - style: TextStyle(fontSize: 16, color: Colors.black87), - ), + const Text('作业行距(米)', style: TextStyle(fontSize: 16, color: Colors.black87)), Row( children: [ // 减号按钮 @@ -265,23 +234,13 @@ class _BottomOperationPanelState extends State { child: Container( width: 30, height: 30, - decoration: BoxDecoration( - color: Colors.grey[200], - shape: BoxShape.circle, - ), - child: const Icon( - Icons.remove, - size: 16, - color: Colors.black87, - ), + decoration: BoxDecoration(color: Colors.grey[200], shape: BoxShape.circle), + child: const Icon(Icons.remove, size: 16, color: Colors.black87), ), ), const SizedBox(width: 10), // 行距数值 - Text( - '${_operationDistance.toStringAsFixed(1)}', - style: const TextStyle(fontSize: 16, color: Colors.black87), - ), + Text('${_operationDistance.toStringAsFixed(1)}', style: const TextStyle(fontSize: 16, color: Colors.black87)), const SizedBox(width: 10), // 加号按钮 GestureDetector( @@ -294,15 +253,8 @@ class _BottomOperationPanelState extends State { child: Container( width: 30, height: 30, - decoration: BoxDecoration( - color: Colors.grey[200], - shape: BoxShape.circle, - ), - child: const Icon( - Icons.add, - size: 16, - color: Colors.black87, - ), + decoration: BoxDecoration(color: Colors.grey[200], shape: BoxShape.circle), + child: const Icon(Icons.add, size: 16, color: Colors.black87), ), ), ], @@ -314,10 +266,7 @@ class _BottomOperationPanelState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text( - '航线方向', - style: TextStyle(fontSize: 16, color: Colors.black87), - ), + const Text('航线方向', style: TextStyle(fontSize: 16, color: Colors.black87)), // 设置按钮 ElevatedButton( onPressed: () { @@ -328,9 +277,7 @@ class _BottomOperationPanelState extends State { style: ElevatedButton.styleFrom( backgroundColor: const Color(0xFF00C853), foregroundColor: Colors.white, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6), - ), + shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)), ), child: const Text('设置'), ), @@ -342,12 +289,7 @@ class _BottomOperationPanelState extends State { } // 构建操作按钮 - Widget _buildActionButton( - IconData icon, - String label, - bool isEnabled, - VoidCallback onTap, - ) { + Widget _buildActionButton(IconData icon, String label, bool isEnabled, VoidCallback onTap) { return GestureDetector( onTap: isEnabled ? onTap : null, child: Column( @@ -355,17 +297,11 @@ class _BottomOperationPanelState extends State { Container( width: 40, height: 40, - decoration: BoxDecoration( - color: isEnabled ? Colors.blue : Colors.grey[300], - shape: BoxShape.circle, - ), + decoration: BoxDecoration(color: isEnabled ? Colors.blue : Colors.grey[300], shape: BoxShape.circle), child: Icon(icon, color: Colors.white), ), const SizedBox(height: 6), - Text( - label, - style: TextStyle(color: isEnabled ? Colors.black : Colors.grey), - ), + Text(label, style: TextStyle(color: isEnabled ? Colors.black : Colors.grey)), ], ), );