Merge FB-07: fix Route Planner opening on Null Island
# Conflicts: # docs/feedback/FB-07-route-planner-null-island.md
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