From 736522da3844385cd8d6172fe25546aa9683fb5f Mon Sep 17 00:00:00 2001 From: Christian Bernier Date: Wed, 16 Sep 2026 15:16:23 -0400 Subject: [PATCH] fix(ios): apply the travel mode to the navigation session The travel mode passed in routingOptions or routeTokenOptions was only set on the map views registered at that instant, never on the GMSNavigationSession whose navigator computes the route. When setDestinations runs before the NavigationView has attached to the session, which is the case for the first request after a launch when the view mounts in the same commit, the session keeps its default of driving and a cycling or walking request comes back as a driving route. Set the mode on the session before updating the views, and have a view that attaches later take the session's mode instead of a fresh map view's default. --- ios/react-native-navigation-sdk/NavModule.mm | 6 +++++- ios/react-native-navigation-sdk/NavViewController.mm | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ios/react-native-navigation-sdk/NavModule.mm b/ios/react-native-navigation-sdk/NavModule.mm index 24b5f0c..d801857 100644 --- a/ios/react-native-navigation-sdk/NavModule.mm +++ b/ios/react-native-navigation-sdk/NavModule.mm @@ -616,8 +616,12 @@ + (GMSNavigationRoutingOptions *)routingOptionsWithStrategy:(std::optional)travelMode { if (travelMode.has_value()) { + GMSNavigationTravelMode mode = (GMSNavigationTravelMode)travelMode.value(); + if (_session != nil) { + _session.travelMode = mode; + } NavViewModule *navViewModule = [NavViewModule sharedInstance]; - [navViewModule setTravelMode:(GMSNavigationTravelMode)travelMode.value()]; + [navViewModule setTravelMode:mode]; } } diff --git a/ios/react-native-navigation-sdk/NavViewController.mm b/ios/react-native-navigation-sdk/NavViewController.mm index e8a4507..c3bd4ca 100644 --- a/ios/react-native-navigation-sdk/NavViewController.mm +++ b/ios/react-native-navigation-sdk/NavViewController.mm @@ -144,6 +144,7 @@ - (BOOL)attachToNavigationSessionIfNeeded { if (result) { _isSessionAttached = YES; _mapView.navigationUIDelegate = self; + [_mapView setTravelMode:session.travelMode]; [self applyStylingOptions]; [self restoreNavigationUIState]; [self applyTrafficPromptsSetting];