删除冗余注释
This commit is contained in:
@@ -153,16 +153,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
_currentStation = _stationList.first;
|
_currentStation = _stationList.first;
|
||||||
_traceManager = TracePoint<PlotPoint>();
|
_traceManager = TracePoint<PlotPoint>();
|
||||||
_initLocationEnterprise();
|
_initLocationEnterprise();
|
||||||
//_traceManager.onCurrentPointUpdated = (point) {
|
|
||||||
// setState(() {
|
|
||||||
// _currentTracePoints = _traceManager.getTracePoint();
|
|
||||||
// });
|
|
||||||
//};
|
|
||||||
//_traceManager.onCompletePointAdded = (point) {
|
|
||||||
// setState(() {
|
|
||||||
// _currentTracePoints = _traceManager.getTracePoint();
|
|
||||||
// });
|
|
||||||
//};
|
|
||||||
|
|
||||||
// 示例:切换到导航模式
|
// 示例:切换到导航模式
|
||||||
_traceManager.setMode(TPMode.LOCATION);
|
_traceManager.setMode(TPMode.LOCATION);
|
||||||
@@ -202,17 +192,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
final bounds = calculateBounds(points);
|
final bounds = calculateBounds(points);
|
||||||
if (bounds == null) return;
|
if (bounds == null) return;
|
||||||
final currentZoom = _mapController.camera?.zoom ?? 18.0;
|
final currentZoom = _mapController.camera?.zoom ?? 18.0;
|
||||||
|
|
||||||
// 移动地图到边界中心(自动适配缩放级别)
|
|
||||||
//_mapController.fitBounds(
|
|
||||||
// bounds,
|
|
||||||
|
|
||||||
// options: FitBoundsOptions(
|
|
||||||
// padding: const EdgeInsets.all(50), // 边缘留白(避免内容贴边)
|
|
||||||
// //maxZoom: 18, // 最大缩放级别(防止过度放大)
|
|
||||||
// ),
|
|
||||||
//);
|
|
||||||
|
|
||||||
_mapController.move(
|
_mapController.move(
|
||||||
bounds.center, // 边界中心点
|
bounds.center, // 边界中心点
|
||||||
currentZoom, // 保留当前缩放比例
|
currentZoom, // 保留当前缩放比例
|
||||||
@@ -247,43 +226,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
return lat != 0 && lng != 0 && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;
|
return lat != 0 && lng != 0 && lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void _updateMarkers() {
|
|
||||||
// if (_currentLatLng == null) {
|
|
||||||
// _markers = {};
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 构建flutter_map的Marker
|
|
||||||
// _markers = {
|
|
||||||
// Marker(
|
|
||||||
// // 标记点坐标
|
|
||||||
// point: _currentLatLng!,
|
|
||||||
// // 标记点宽高
|
|
||||||
// width: 40,
|
|
||||||
// height: 40,
|
|
||||||
// // 标记点样式(替换为你的自定义样式,先试用默认容器验证)
|
|
||||||
// child: Container(
|
|
||||||
// decoration: BoxDecoration(
|
|
||||||
// color: Colors.red,
|
|
||||||
// borderRadius: BorderRadius.circular(20),
|
|
||||||
// border: Border.all(color: Colors.white, width: 2),
|
|
||||||
// ),
|
|
||||||
// child: const Center(child: Text('🚗', style: TextStyle(fontSize: 20))),
|
|
||||||
// // 如果你有自定义Painter,替换为:
|
|
||||||
// // child: CustomPaint(
|
|
||||||
// // size: const Size(40, 40),
|
|
||||||
// // painter: HeadingMarkerPainter(headingAngle: _headingAngle),
|
|
||||||
// // ),
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
// };
|
|
||||||
|
|
||||||
// // 触发UI刷新(flutter_map会自动更新标记点)
|
|
||||||
// if (mounted) {
|
|
||||||
// setState(() {});
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void _onDeviceData(double lng, double lat, bool obfFlag, int headingStatus, controlMode) {
|
void _onDeviceData(double lng, double lat, bool obfFlag, int headingStatus, controlMode) {
|
||||||
try {
|
try {
|
||||||
// 1. 校验坐标有效性
|
// 1. 校验坐标有效性
|
||||||
@@ -528,19 +470,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
return polygonPoints;
|
return polygonPoints;
|
||||||
}
|
}
|
||||||
|
|
||||||
//void _undoLastPoint() {
|
|
||||||
// if (_markedPoints.isNotEmpty) {
|
|
||||||
// setState(() {
|
|
||||||
// _markedPoints.removeLast(); // 删除最后一个打点
|
|
||||||
// });
|
|
||||||
// debugPrint('撤回成功,剩余打点数量:${_markedPoints.length}');
|
|
||||||
// } else {
|
|
||||||
// debugPrint('无打点可撤回');
|
|
||||||
// // 可选:提示用户
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('暂无打点可撤回')));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
// ========== 统一撤回方法(适配完成后状态) ==========
|
// ========== 统一撤回方法(适配完成后状态) ==========
|
||||||
void _undoAction() {
|
void _undoAction() {
|
||||||
setState(() {
|
setState(() {
|
||||||
@@ -632,21 +561,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 核心:清空所有打点和轨迹 ==========
|
|
||||||
//void _deleteAllPoints() {
|
|
||||||
// if (_markedPoints.isNotEmpty) {
|
|
||||||
// setState(() {
|
|
||||||
// _markedPoints.clear(); // 清空所有打点
|
|
||||||
// });
|
|
||||||
// debugPrint('删除成功,已清空所有打点和轨迹');
|
|
||||||
// // 可选:提示用户
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('已清空所有打点和轨迹')));
|
|
||||||
// } else {
|
|
||||||
// debugPrint('无打点可删除');
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('暂无打点可删除')));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
void _handleGotoLocation() {
|
void _handleGotoLocation() {
|
||||||
_mapController.move(_currentLatLng!, 18);
|
_mapController.move(_currentLatLng!, 18);
|
||||||
}
|
}
|
||||||
@@ -791,30 +705,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
ToastUtils.showSuccess(context, '已添加第${_obstacleHoles.length}个障碍物区域');
|
ToastUtils.showSuccess(context, '已添加第${_obstacleHoles.length}个障碍物区域');
|
||||||
}
|
}
|
||||||
|
|
||||||
//void _undoObstaclePoint() {
|
|
||||||
// if (_currentObstaclePoints.isNotEmpty) {
|
|
||||||
// setState(() => _currentObstaclePoints.removeLast());
|
|
||||||
// debugPrint('撤回障碍物打点,剩余:${_currentObstaclePoints.length}个');
|
|
||||||
// } else if (_obstacleHoles.isNotEmpty) {
|
|
||||||
// // 无当前绘制点时,删除最后一组障碍物
|
|
||||||
// setState(() => _obstacleHoles.removeLast());
|
|
||||||
// debugPrint('删除最后一组障碍物,剩余组数:${_obstacleHoles.length}');
|
|
||||||
// } else {
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('暂无障碍物打点可撤回')));
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//// ========== 障碍物模式:清空所有障碍物 ==========
|
|
||||||
//void _clearAllObstacles() {
|
|
||||||
// setState(() {
|
|
||||||
// _obstacleHoles.clear();
|
|
||||||
// _currentObstaclePoints.clear();
|
|
||||||
// _isObstacleEditing = false;
|
|
||||||
// });
|
|
||||||
// debugPrint('已清空所有障碍物区域');
|
|
||||||
// ScaffoldMessenger.of(context).showSnackBar(const SnackBar(content: Text('已清空所有障碍物区域'), backgroundColor: Colors.amber));
|
|
||||||
//}
|
|
||||||
|
|
||||||
// ========== 核心方法:打点逻辑 ==========
|
// ========== 核心方法:打点逻辑 ==========
|
||||||
void _addMarkedPoint() {
|
void _addMarkedPoint() {
|
||||||
if (_currentAreaMode == AreaMode.work && _isWorkAreaCompleted) {
|
if (_currentAreaMode == AreaMode.work && _isWorkAreaCompleted) {
|
||||||
@@ -874,21 +764,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模拟添加完成点
|
|
||||||
void _addCompletePoint() {
|
|
||||||
final newPoint = LatLng(39.9042 + (DateTime.now().millisecond / 10000), 116.4074 + (DateTime.now().millisecond / 10000));
|
|
||||||
_traceManager.upsert(newPoint, TPAction.ADD);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 模拟更新当前点
|
|
||||||
void _updateCurrentPoint() {
|
|
||||||
final newPoint = LatLng(39.9042 + (DateTime.now().millisecond / 10000), 116.4074 + (DateTime.now().millisecond / 10000));
|
|
||||||
_traceManager.upsert(newPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 构建视频弹窗
|
|
||||||
// 构建视频小弹窗(可拖拽)
|
|
||||||
// 构建视频小弹窗(可拖拽)
|
|
||||||
Widget _buildVideoPopup() {
|
Widget _buildVideoPopup() {
|
||||||
return Positioned(
|
return Positioned(
|
||||||
left: _videoPopupPos.dx,
|
left: _videoPopupPos.dx,
|
||||||
@@ -933,97 +808,6 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
final cubitState = context.read<DevicesCubit>().state;
|
final cubitState = context.read<DevicesCubit>().state;
|
||||||
final _loadedPlot = cubitState.pathData;
|
final _loadedPlot = cubitState.pathData;
|
||||||
print('加载地块「${plot.plotName}」的路径数据: $_loadedPlot');
|
print('加载地块「${plot.plotName}」的路径数据: $_loadedPlot');
|
||||||
|
|
||||||
// 2. 立即解析并更新状态(在事件回调中,不在 build 中)
|
|
||||||
//if (_loadedPlot is List) {
|
|
||||||
// final List<dynamic> rawList = _loadedPlot as List<dynamic>;
|
|
||||||
// final pathRecords = rawList.where((item) => item is Map<String, dynamic>).cast<Map<String, dynamic>>().toList();
|
|
||||||
|
|
||||||
// // 打印:过滤后的 pathRecords 长度和第一条数据的顶层字段
|
|
||||||
// print('🔍 过滤后 pathRecords 长度: ${pathRecords.length}');
|
|
||||||
// if (pathRecords.isNotEmpty) {
|
|
||||||
// final Map<String, dynamic> firstRecord = pathRecords.first;
|
|
||||||
// print('📋 第一条记录的顶层字段:');
|
|
||||||
// print(' - id: ${firstRecord['id']}');
|
|
||||||
// print(' - workName: ${firstRecord['workName']}');
|
|
||||||
// print(' - userId: ${firstRecord['userId']}');
|
|
||||||
// print(' - jsonData (原始字符串长度): ${firstRecord['jsonData']?.toString().length ?? 0} 字符');
|
|
||||||
// print('------------------------------------');
|
|
||||||
|
|
||||||
// final selectedPlotPath = PlotDataPath(jsonData: firstRecord);
|
|
||||||
// try {
|
|
||||||
// final dynamic nestedJsonRaw = selectedPlotPath.jsonData['jsonData'];
|
|
||||||
// print('📦 嵌套 jsonData 原始类型: ${nestedJsonRaw.runtimeType}');
|
|
||||||
// print('📦 嵌套 jsonData 前200字符: ${nestedJsonRaw?.toString().substring(0, min(200, nestedJsonRaw?.toString().length ?? 0))}...');
|
|
||||||
|
|
||||||
// if (nestedJsonRaw != null && nestedJsonRaw is String) {
|
|
||||||
// final String nestedJsonStr = nestedJsonRaw;
|
|
||||||
// final dynamic parsedJson = jsonDecode(nestedJsonStr);
|
|
||||||
// print('✅ 嵌套 JSON 解析成功,类型: ${parsedJson.runtimeType}');
|
|
||||||
|
|
||||||
// // 格式化打印完整的嵌套 JSON(排除 img 字段,避免刷屏)
|
|
||||||
// if (parsedJson is Map<String, dynamic>) {
|
|
||||||
// final Map<String, dynamic> nestedJson = Map.from(parsedJson);
|
|
||||||
// // 截断 img 字段的 Base64 数据
|
|
||||||
// if (nestedJson.containsKey('img')) {
|
|
||||||
// final String imgBase64 = nestedJson['img'] as String;
|
|
||||||
// nestedJson['img'] = imgBase64.substring(0, min(50, imgBase64.length)) + '...(Base64 已截断)';
|
|
||||||
// }
|
|
||||||
// print('📝 格式化嵌套 JSON 数据:');
|
|
||||||
// print(const JsonEncoder.withIndent(' ').convert(nestedJson));
|
|
||||||
// print('------------------------------------');
|
|
||||||
|
|
||||||
// // 解析作业模式并打印
|
|
||||||
// final dynamic planModel = nestedJson['planModel'];
|
|
||||||
// workMode = planModel == WorkMode.bow.value ? "弓字模式" : "自定义模式";
|
|
||||||
// print('⚙️ 解析出作业模式: $workMode (原始 planModel 值: $planModel)');
|
|
||||||
|
|
||||||
// // 解析 Path 并打印明细
|
|
||||||
// final dynamic rawPath = nestedJson['path'];
|
|
||||||
// List<dynamic> pathList = rawPath is List ? rawPath : [];
|
|
||||||
// print('🗺️ 解析出 Path 数据:');
|
|
||||||
// print(' - Path 类型: ${rawPath.runtimeType}');
|
|
||||||
// print(' - Path 长度: ${pathList.length} 个点');
|
|
||||||
// // 逐点打印前 5 个 Path 坐标(避免点太多刷屏)
|
|
||||||
// for (int i = 0; i < min(5, pathList.length); i++) {
|
|
||||||
// final dynamic point = pathList[i];
|
|
||||||
// print(' - Path 点 $i: lat=${point['lat']}, lon=${point['lon']} (或 lng=${point['lng']})');
|
|
||||||
// }
|
|
||||||
// if (pathList.length > 5) {
|
|
||||||
// print(' - ... 还有 ${pathList.length - 5} 个点未显示');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 解析 Outer 并打印明细
|
|
||||||
// final dynamic rawOuter = nestedJson['outer'];
|
|
||||||
// List<dynamic> outerList = rawOuter is List ? rawOuter : [];
|
|
||||||
// print('📏 解析出 Outer 外边界数据:');
|
|
||||||
// print(' - Outer 类型: ${rawOuter.runtimeType}');
|
|
||||||
// print(' - Outer 长度: ${outerList.length} 个点');
|
|
||||||
// // 逐点打印前 5 个 Outer 坐标
|
|
||||||
// for (int i = 0; i < min(5, outerList.length); i++) {
|
|
||||||
// final dynamic point = outerList[i];
|
|
||||||
// print(' - Outer 点 $i: lat=${point['lat']}, lon=${point['lon']} (或 lng=${point['lng']})');
|
|
||||||
// }
|
|
||||||
// if (outerList.length > 5) {
|
|
||||||
// print(' - ... 还有 ${outerList.length - 5} 个点未显示');
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 后续坐标转换逻辑(保持你的原有代码)
|
|
||||||
// // ...(这里放你原来的坐标转换、setState 逻辑)
|
|
||||||
// } else {
|
|
||||||
// print('❌ 解析失败:嵌套 JSON 不是 Map 类型,实际类型: ${parsedJson.runtimeType}');
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// print('❌ 解析失败:nestedJsonRaw 为空或不是字符串,实际值: $nestedJsonRaw,类型: ${nestedJsonRaw?.runtimeType}');
|
|
||||||
// }
|
|
||||||
// } catch (e, stackTrace) {
|
|
||||||
// print('❌ 解析嵌套 JSON 时发生异常: $e');
|
|
||||||
// print('📜 异常堆栈: $stackTrace');
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// print('❌ 过滤后 pathRecords 为空,无有效数据');
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
if (_loadedPlot is List) {
|
if (_loadedPlot is List) {
|
||||||
final List<dynamic> rawList = _loadedPlot as List<dynamic>;
|
final List<dynamic> rawList = _loadedPlot as List<dynamic>;
|
||||||
final pathRecords = rawList.where((item) => item is Map<String, dynamic>).cast<Map<String, dynamic>>().toList();
|
final pathRecords = rawList.where((item) => item is Map<String, dynamic>).cast<Map<String, dynamic>>().toList();
|
||||||
@@ -2223,23 +2007,10 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
onUndoTap: () {
|
onUndoTap: () {
|
||||||
// 区分模式:作业区域撤回/障碍物撤回
|
|
||||||
//if (_currentAreaMode == AreaMode.work) {
|
|
||||||
// _undoLastPoint();
|
|
||||||
//} else {
|
|
||||||
// _undoObstaclePoint();
|
|
||||||
//}
|
|
||||||
_undoAction();
|
_undoAction();
|
||||||
},
|
},
|
||||||
onDeleteTap: () {
|
onDeleteTap: () {
|
||||||
_deleteAllAction();
|
_deleteAllAction();
|
||||||
|
|
||||||
// 区分模式:作业区域清空/障碍物清空
|
|
||||||
//if (_currentAreaMode == AreaMode.work) {
|
|
||||||
// _deleteAllPoints();
|
|
||||||
//} else {
|
|
||||||
// _clearAllObstacles();
|
|
||||||
//}
|
|
||||||
},
|
},
|
||||||
onRobotModeChanged: (mode) {
|
onRobotModeChanged: (mode) {
|
||||||
setState(() => _currentRobotMode = mode);
|
setState(() => _currentRobotMode = mode);
|
||||||
|
|||||||
Reference in New Issue
Block a user