fix(ios): apply the travel mode to the navigation session - #656
Open
christian-apollo wants to merge 1 commit into
Open
christian-apollo wants to merge 1 commit into
christian-apollo wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On iOS the travel mode passed to
setDestinationswas only applied to theGMSMapViewof each registeredNavigationView, never to theGMSNavigationSessionwhose navigator computes the route. WhensetDestinationsruns before the view has attached to the session (the first request after a launch, when the view mounts in the same React commit that starts guidance), the session keeps its default of driving and a cycling or walking request comes back as a driving route. Re-issuing the request once the view is attached works, which is the workaround users find.This sets the mode on the session in
configureNavigatorWithTravelMode:before the views are updated, so the request itself carries it, and makes a view that attaches later take the session's mode inattachToNavigationSessionIfNeededinstead of keeping a fresh map view's default.Verified on an iPhone 17 Pro simulator (iOS 26.4, RN 0.86.3) with a cold launch and a destination chosen from a plain
MapView: before, the first route was 18.2 km in 46 min withdelaySeverity: 2(a driving route); after, 29.6 km in 96 min withdelaySeverity: 0, identical to an explicit cycling request on an attached view. Walking and driving requests still return their own routes. Android is untouched: itsRoutingOptionscarry the mode per request.Fixes #655
Pre-launch Checklist