重整多余的UI组件和未定功能的逻辑链路的修正

This commit is contained in:
2026-11-11 16:33:04 +08:00
parent 34cb9d2805
commit 47f518f94c
100 changed files with 5789 additions and 3070 deletions

View File

@@ -55,6 +55,7 @@ class PvWorkMap extends StatefulWidget {
this.draftCrosshair = false,
this.returnPoints = const <LatLng>[],
this.followDevice = true,
this.centerOnDeviceOnOpen = false,
this.recenterSignal = 0,
this.clearTraceSignal = 0,
this.onCenterChanged,
@@ -66,9 +67,12 @@ class PvWorkMap extends StatefulWidget {
this.traceDiagnosticsEnabled = false,
this.showDevice = true,
this.extraMapLayers = const <Widget>[],
this.foregroundMapLayer,
this.onMapTap,
this.focusPoints = const <LatLng>[],
this.focusSignal = 0,
this.focusPadding = const EdgeInsets.all(40),
this.focusMaxZoom,
});
/// 设备 SN:用于过滤路线推送(deviceId 不匹配的消息直接丢弃)。
@@ -139,6 +143,9 @@ class PvWorkMap extends StatefulWidget {
/// 否则每次定位推送都会把地图挪走,正在打的位置就跑了。
final bool followDevice;
/// 打开地图时优先使用已收到的设备位置。
final bool centerOnDeviceOnOpen;
/// 外部「回到设备位置」信号:每次 +1 就把地图移回设备当前坐标
/// (与路径规划竖浮菜单的「定位」同一个行为)。
final int recenterSignal;
@@ -163,9 +170,12 @@ class PvWorkMap extends StatefulWidget {
/// 业务页面提供独立叠加层,共享地图无需依赖具体分区业务。
final List<Widget> extraMapLayers;
final Widget? foregroundMapLayer;
final ValueChanged<LatLng>? onMapTap;
final List<LatLng> focusPoints;
final int focusSignal;
final EdgeInsets focusPadding;
final double? focusMaxZoom;
@override
State<PvWorkMap> createState() => _PvWorkMapState();
@@ -339,7 +349,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
CameraFit.bounds(
bounds: LatLngBounds.fromPoints(widget.focusPoints),
padding: widget.focusPadding,
maxZoom: _previewZoom,
maxZoom: widget.focusMaxZoom ?? _previewZoom,
),
);
});
@@ -546,7 +556,10 @@ class _PvWorkMapState extends State<PvWorkMap> {
FlutterMap(
mapController: _map,
options: MapOptions(
initialCenter: _pos ?? _fallbackCenter(),
initialCenter:
_pos ??
(widget.centerOnDeviceOnOpen ? marker : null) ??
_fallbackCenter(),
initialZoom: _centerZoom,
maxZoom: 22,
minZoom: 3,
@@ -558,7 +571,9 @@ class _PvWorkMapState extends State<PvWorkMap> {
),
onMapReady: () {
_ready = true;
if (widget.onDevicePosition != null && widget.showDevice) {
if (widget.showDevice &&
(widget.centerOnDeviceOnOpen ||
widget.onDevicePosition != null)) {
final current = context.read<DeviceStatusBloc>().state;
if (current is DeviceStatusUpdated) _onLocation(current);
}
@@ -577,7 +592,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
},
onPositionChanged: _notifyCenter,
onMapEvent: _onMapEvent,
onTap: (_, _) {}, // 空实现:地图本身不响应点击
onTap: (_, point) => widget.onMapTap?.call(point),
),
children: [
/// 底图:中文=ESRI,非中文=Google(不可达自动回退 ESRI)
@@ -927,6 +942,7 @@ class _PvWorkMapState extends State<PvWorkMap> {
),
],
),
?widget.foregroundMapLayer,
],
),
// 还没收到定位推送时的提示(此时图面停在场站中心,机器不出现)