定位的逻辑

This commit is contained in:
mmc
2026-03-10 08:58:44 +08:00
parent 919afde01e
commit 58d5e8bf9f
2 changed files with 13 additions and 2 deletions

View File

@@ -629,8 +629,13 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// }
//}
void _handleGotoLocation() {
_mapController.move(_currentLatLng!, 18);
}
/// ===============================
/// 企业级定位初始化(已修复坐标系)
///
Future<void> _initLocationEnterprise() async {
// 1. 设置轨迹模式为 LOCATION(核心:确保模式正确)
_traceManager.setMode(TPMode.LOCATION);
@@ -692,8 +697,8 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
// 4. 重置轨迹管理器
_traceManager.reset();
if (_isValidLatLng(_mapCenter.latitude, _mapCenter.longitude)) {
_mapController.move(_mapCenter, savedZoom);
if (_currentLatLng != null && _isValidLatLng(_currentLatLng!.latitude, _currentLatLng!.longitude)) {
_mapController.move(_currentLatLng!, savedZoom);
} else {
// 使用兜底的有效坐标(确保在高德瓦片覆盖范围内)
final defaultCenter = _getDefaultValidCenter();
@@ -2154,6 +2159,7 @@ class _MapPageEnterpriseState extends State<MapPageEnterprise> {
_currentWorkMode = mode;
debugPrint('外部收到作业模式:$mode');
},
handleGotoLocation: _handleGotoLocation,
onRefreshTap: _handleRefresh, // 推荐用局部刷新
onVideoTap: _handleVideo,
),

View File

@@ -8,6 +8,7 @@ class VerticalFloatMenu extends StatefulWidget {
final ValueChanged<WorkMode>? onWorkModeSelected;
final VoidCallback? onRefreshTap; // 新增刷新回调
final VoidCallback? onVideoTap;
final VoidCallback? handleGotoLocation;
const VerticalFloatMenu({
super.key,
@@ -17,6 +18,7 @@ class VerticalFloatMenu extends StatefulWidget {
this.onWorkModeSelected,
this.onRefreshTap, // 接收刷新回调
this.onVideoTap,
this.handleGotoLocation,
});
@override
@@ -75,6 +77,9 @@ class _VerticalFloatMenuState extends State<VerticalFloatMenu> {
if (index == 1) {
widget.onListBox?.call(true);
}
if (index == 3) {
widget.handleGotoLocation?.call();
}
if (index == 4) {
// 触发外部传入的刷新回调
widget.onRefreshTap?.call();