Repository navigation
feat: let a map view factory hand over a map that lives elsewhere - #4412
Merged
Merged
Conversation
mfazekas
force-pushed
the
feat/map-view-factory-external-map
branch
from
October 27, 2026 07:03
0d3b8f0 to
93bf3cc
Compare
mfazekas
marked this pull request as ready for review
October 27, 2026 09:10
mfazekas
added a commit
to rnmapbox/navigation
that referenced
this pull request
Oct 27, 2026
<CarMap> uses the map view factory support for maps that live elsewhere from rnmapbox/maps#4412, released in 10.3.15.
This was referenced Oct 27, 2026
mfazekas
added a commit
to rnmapbox/navigation
that referenced
this pull request
Oct 27, 2026
* feat(ios): prototype CarPlay support on the shared navigation session CarPlay shows the Navigation SDK's CarPlayManager UI for the same session as the phone: the map while idle and turn-by-turn guidance while guidance runs. The Expo plugin's carPlay option adds the CarPlay scene and the carplay-maps entitlement. The plugin now also adds the audio background mode, without which the SDK asserts in debug builds when guidance starts. * feat: add CarMap for @rnmapbox/maps children on the car screen's map * feat(ios): CarMap on the CarPlay map, and create the session when the car connects * feat(android): CarMap on Android Auto and a debug car screen preview RNMBXNavigationCarMaps hands the car screen's MapSurface to <CarMap>'s rnmbxnavcar map. RNMBXNavigationCarMapSurface draws that map onto a car Surface, fed by the Android Auto SurfaceCallback (CarAppService declared by the plugin's androidAuto option) or, in debug builds, by a SurfaceView overlay toggled with an adb broadcast. * fix(ios): start the CarPlay session without React Native CarPlay can cold-launch the app with only the CarPlay scene, so JS never sets the access token. Fall back to the Maps SDK token (Info.plist MBXAccessToken) to create the navigation provider, which JS then reuses. * docs: CarPlay entitlement, Info.plist token and a simulator shim for development * fix: build against Navigation SDK 3.33 and a nullable RNMBXMapView.mapView Nav SDK 3.33 moved the CarPlayManagerDelegate defaults this delegate relies on to the MapboxCarPlayInternal SPI. On Android, maps #4412 now exposes RNMBXMapView.mapView as optional. * feat(example): highlight the car's position on the car screen's map A ring that follows the navigation location and larger POI circles, drawn with @rnmapbox/maps layers through <CarMap>. * feat(ios): a CarPlay React root, so <CarMap> renders on a CarPlay-only launch Navigation.registerCarPlayRoot registers a component that the CarPlay scene mounts in a React root of its own while CarPlay is connected, on the app's React Native factory. When CarPlay launches the app without its phone UI, that root starts React Native; the phone scene later shares the same host. The Expo plugin's carPlay option hands the factory to the CarPlay scene in AppDelegate.swift. The host is still created on demand, so a phone cold start keeps its launch options for Linking.getInitialURL. The example renders its car map layers in that root on iOS and keeps them emissive so the night style doesn't darken them. * chore: require @rnmapbox/maps 10.3.15 for CarMap <CarMap> uses the map view factory support for maps that live elsewhere from rnmapbox/maps#4412, released in 10.3.15. * fix(ios): keep the phone's trip when CarPlay takes over guidance CarPlayNavigationViewController always starts active guidance from leg 0 in viewDidLoad, so CarPlay connecting mid-trip set a multi-leg trip back to its first leg, and a trip the phone stopped while CarPlay was still starting came back. Restore the leg index right after the view controller restarts guidance, and end CarPlay's guidance again if the phone stopped meanwhile. * fix(ios): one CarPlay React root per process, created without reflection Reconnecting CarPlay created a second root while the first one's surface could still run, mounting <CarMap> twice on the same map. The root is now created once and moved to each new CarPlay window. An Objective-C helper creates it with React Native's own root view API, with a fallback for versions before 0.84, instead of key-value lookups and an unsafe cast; the factory property is typed. The provider sink waits until the session has set its provider, and setting a different token after CarPlay created the provider logs a warning instead of being ignored silently. * feat: make the CarPlay root opt-in, and let <CarMap> find its place The CarPlay root wraps the registered component in a context. While it is mounted, <CarMap> elsewhere in the app renders nothing, so the same component can be rendered in the app for Android Auto and registered as the CarPlay root without duplicating layers on iOS. The plugin hands the factory to CarPlay only with carPlayRoot: true, so apps that use the stock CarPlay UI don't start React Native on a CarPlay-only launch. It warns instead of failing the prebuild for an app delegate it doesn't know, and removes its scene, app delegate lines and Android Auto service when the options are turned off. The audio background mode moves to its own change. CAR_MAP_VIEW_IMPL and the car event types are no longer exported. * refactor(android): ship the car screen preview in debug builds only It moves to the library's debug source set, with a no-op in release. Its receiver is registered once and uses the latest React context, so it keeps working after a JS reload instead of holding on to the first one. * docs: CarPlay root, CarMap placement, Android Auto and plugin options
This branch was previously deployed
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.
Description
Lets a registered
RNMBXMapViewFactory(the hooks from #4289 and #4369) hand over a map that lives elsewhere.RNMBXMapViewthen adds its children (sources, layers, images) to that map and removes them again, but leaves the map's style, ornaments, gestures, frame and lifetime to whoever owns it. This is what the CarPlay / Android Auto<CarMap>prototype in rnmapbox/navigation needs (rnmapbox/navigation#17).RNMBXMapView.ownsMapView(defaulttrue). A factory returning the map Mapbox Navigation'sCarPlayManagercreated sets it tofalse. The view then doesn't take over the gesture delegate or remove the map on teardown, picks up a style that is already loaded, and re-adds its features when the owner swaps the style.RNMBXMapViewFactory.registerExternalMapreturns anRNMBXExternalMap(aMapboxMap, its plugin provider, and an optionalMapView), so the map can be aMapSurface.RNMBXMapView.mapViewis nowMapView?: null before the map is created and for an external map without aMapView. Internals usemapPlugins(gestures, location, viewport, annotations) andgetMapboxMap(); ornaments, snapshots and touch handling skip a missingMapView, andMarkerView/PointAnnotationchildren are skipped with a warning. Map props are ignored for an external map.The nullable
mapViewis an SPI change: Kotlin callers ofRNMBXMapView.mapViewneed?.or a null check (e.g.RNMBXNavigationViewportin rnmapbox/navigation).Rebased onto
main, so this needs Mapbox Maps 11.33. On iOS, 11.33'sMapView.didMoveToWindowseeds the scene fromCPWindow.templateApplicationScene, so a car map added after the CarPlay scene activated starts its display link; 11.23 doesn't.Checked:
yarn lint,yarn type:check,yarn unittest,yarn generate(no drift), and example app builds for Android and the iOS simulator. Not re-tested on a device or car screen after the rebase.Checklist
CONTRIBUTING.mdyarn generatein the root folder/exampleapp./example)