FB-07: fix Route Planner opening on Null Island
A brand-new route (or one with fewer than two pins) now falls back to the ambient GPS position for its initial map center instead of (0, 0) in the middle of the ocean, reusing FB-01's ambientPositionProvider. Routes with one or more real waypoints are unaffected. Falls back to (0, 0) as before when no ambient fix is available. Adds three widget tests covering the fixed-fix, no-fix, and real-waypoint-wins cases. Emulator verification was attempted but the Android emulator became unresponsive partway through and was abandoned per the ticket's conservative-use guidance; details in the ticket's Outcome section.
This commit is contained in:
@@ -119,6 +119,16 @@ class _RoutePlannerScreenState extends ConsumerState<RoutePlannerScreen>
|
||||
final units = ref.watch(unitSystemProvider);
|
||||
final repo = ref.read(routePlanRepositoryProvider);
|
||||
|
||||
// FB-07: a brand-new route (or one with <2 pins) should open on the rider's real
|
||||
// location rather than Null Island (0, 0). This mirrors ShellScaffold's own use of
|
||||
// ambientPositionProvider (lib/src/ui/app_shell.dart). A missing fix (permission
|
||||
// denied, service disabled, or not arrived yet) falls back to (0, 0) immediately --
|
||||
// it must not block the map the way waypointsAsync is blocked above.
|
||||
final ambientFix = ref.watch(ambientPositionProvider).valueOrNull;
|
||||
final ambientPosition = ambientFix == null
|
||||
? null
|
||||
: ll.LatLng(ambientFix.latitude, ambientFix.longitude);
|
||||
|
||||
// Mirrors waypointsAsync's own guard below: `.valueOrNull` alone can't tell "still
|
||||
// loading" apart from "genuinely doesn't exist" -- both collapse to null. On a
|
||||
// brand-new route (fresh navigation right after `repo.createRoutePlan`), this
|
||||
@@ -168,7 +178,7 @@ class _RoutePlannerScreenState extends ConsumerState<RoutePlannerScreen>
|
||||
options: MapOptions(
|
||||
initialCameraFit: _initialFit(waypoints),
|
||||
initialCenter: waypoints.isEmpty
|
||||
? const ll.LatLng(0, 0)
|
||||
? (ambientPosition ?? const ll.LatLng(0, 0))
|
||||
: ll.LatLng(waypoints.first.latitude, waypoints.first.longitude),
|
||||
initialZoom: waypoints.length <= 1 ? ambientZoom : maxTileZoom - 3,
|
||||
maxZoom: maxTileZoom,
|
||||
|
||||
Reference in New Issue
Block a user