CarPlay and Android Auto
Meridian Atlas puts your navigation app on the car's screen: CarPlay on iOS and Android Auto on Android, from the Swift, Android, React Native and Flutter SDKs. The car screen shows:
- the Atlas map, following the car;
- map buttons: zoom, pan, the route overview and recentre;
- night mode, following the car's headlights, or held in day or night by your app in one line (Day and night);
- a route preview to choose from.
While guiding, it adds:
- manoeuvres in the route's UK wording, with junction and exit numbers and roundabout exits;
- lanes;
- the time and distance left;
- reroutes;
- each stop of a multi-stop trip: the time and distance to the next, the stops still to come with their arrival times, and "Skip this stop" for your app to answer (Multi-stop trips);
- pauses for lost GPS, rerouting and going offline;
- the speed limit sign, with the speed beside it when over the limit, a lower limit ahead, and a speed camera counting down beside it (Speed limits and cameras);
- the manoeuvre and lanes on the instrument cluster and head-up display, where the car has them.
Your app keeps its navigation session. Give the car screen each route you guide along, and each update, as you do your map. React Native and Flutter pass the updates natively, so your code only shows routes.
How it looks and behaves
The car's own templates carry the guidance card, the trip estimates and the buttons, so the car screen looks like the car's other apps. The Atlas map is the only thing drawn in the map area, with one exception: the speed limit sign in its lower corner, and beside it a lower limit ahead or a speed camera, small.
Colours come from Meridian's design tokens. The guidance card is Meridian navy unless your brand's.
The guidance card is kept short, so the map shows round it. CarPlay draws the card itself from what Atlas gives
it: a row of the symbol beside the distance, as tall as the symbol; the instruction; and the lanes picture under it.
On the Simulator's 400 × 240-point car screen it is 72 points tall (30% of the screen) away from junctions and 84
points (35%) near one, with the lanes shown: the figures approved on the night of 2 December (it was 177 points, 74%,
that morning). samples/ios-carplay/card-variants.sh measures it with each set of inputs. Everything else on the car
screen keeps within that budget: a speed camera shows beside the speed sign, not in a panel under the card, and a
multi-stop trip's stops are a list the driver opens, not rows on the card.
- The manoeuvre symbol: 32 points on CarPlay, drawn heavy (4.7-point lines) to read at a glance; the card's first row is as tall as it. Android Auto sizes the symbol itself; Atlas draws it in the car screen's pixels at the 128 dp the Car App Library asks for.
- Lanes, near the junction: the lanes picture is the card's tallest part, so it shows from 300 m before the
junction, or 20 seconds at the car's speed (up to 1.2 km on a motorway), until the junction is passed, as the
driver gets in lane; once shown it stays, so slowing for the junction doesn't take it away. It is 24 points tall
on CarPlay and 40 dp on Android Auto, the lanes to use bright and the best one underlined. CarPlay's instrument
cluster and head-up display get the lanes as data (
CPLaneGuidance) throughout, as does Android Auto's (Lane). - The instruction: one line. Road names are written as UK car screens print them ("John Dalton St", "Oxford Rd"). On a small CarPlay screen the card shows the road alone ("John Dalton St", the arrow saying which way) or a roundabout's exit; a wider one shows the whole instruction. Spoken guidance and the notification on the phone keep the words in full. The wording has the rules.
- "Then" (a second, smaller row for the manoeuvre after the next) only when that one comes within 6 seconds of the next at the car's speed, 75 m at least. The voice still joins two manoeuvres within 8 seconds into one sentence ("Turn right, then turn left").
- Distances in the driver's units, rounded as the phone's panels round them: "80 yd", "0.4 mi", "12 mi" where road signs use miles; "80 m", "1.6 km" elsewhere. CarPlay prints a distance in the unit it is given, so the card read "79.6 m" and the trip "595 m" on a UK car screen before 2 December's evening; Android Auto's already did.
- Pictures at the car's scale: CarPlay reads a picture's pixels at the car screen's display scale, so
Atlas draws the symbol and lanes at that scale (
CPInterfaceController.carTraitCollection), not the iPhone's.
The map buttons are zoom in, zoom out and pan, and a fourth that changes:
- Overview while guiding with the map following the car. It shows the whole remaining route (the car, each stop left and the destination) flat and north-up, clear of the guidance card. CarPlay's or Android Auto's guidance carries on; the zoom and pan buttons move the overview.
- Recentre once the driver has panned or zoomed the map, or in the overview. The map follows the car again at its own distance, tilt and heading.
- Nothing in free drive or a route preview while the map follows the car.
For the car's screen reader, Siri and Voice Control, CarPlay's map buttons are labelled "Zoom in", "Zoom out", "Route overview", "Recentre" and "Pan", an alert's picture is labelled with what it is ("Speed camera", "New route", "Warning"), and the camera beside the sign reads "Speed camera in 250 yards". Android Auto reads an action's title (Retry, End, Stops, Simulate); the Car App Library gives the map's buttons no title or description, so they are icons beside Android Auto's own Pan (Accessibility).
Leaving CarPlay's panning mode (its Done button) recentres the map. Your app can do the same:
showOverview() and recentre() on AtlasCarPlay and AtlasCar, and on React Native's and Flutter's
AtlasCarScreen. With autoRecentreAfter on the car screen's map presentation (off by default; the
navigation guide's "The map"), the map follows the car again by itself after the driver last used the map
buttons.
Both platforms' rules for navigation apps are followed:
- Map buttons:
- at most four on CarPlay (Android Auto's map action strip takes four too);
- panning has its own Done button.
- Navigation bar: two buttons a side on CarPlay (End and Stops on the right; Simulate, in review and debug builds, beside your app's own on the left when Stops takes its place); four actions on Android Auto.
- Speed cameras:
- only for the trip, and drawn on the map only beside the speed sign (the base view holds the map; the sign and its camera are information, not controls);
- only where warning of cameras is lawful (the UK and Ireland; not France, Germany or Switzerland);
- at the same distance as the phone's: 22.4 seconds before the camera at its limit or the car's speed;
- gone once the camera is passed;
- the car's own alert ("Speed camera", "30 mph limit", gone after 6 seconds) only when the map isn't in front: another app on the car screen (CarPlay shows it as a notification, Android Auto as its alert), the Stops list, or the sign turned off.
- Text:
- every manoeuvre comes with shorter forms ("Turn right" after "At the traffic lights, turn right onto Booth Street");
- the car picks the one that fits.
When the car connects mid-trip, the car screen picks up where guidance is. Disconnecting leaves the phone guiding.
Locating, lost GPS and reroutes. The car screens show each snapshot's status (the guidance status,
the SDK guide), as the phone's panels do, never
the raw phase:
| Status | CarPlay | Android Auto |
|---|---|---|
| Locating… (guidance has begun, no usable fix yet; up to 10 s) | the trip paused for .locating, "Locating…" | the card says "Locating…"; the cluster's trip is loading |
| No GPS signal (10 s from the start; mid-drive 3 s after the session's own 5 s) | paused for .locating, "No GPS signal" | "No GPS signal", "Guidance carries on when the signal is back" |
| A few seconds without GPS, a tunnel | the card stays | the card stays |
| Finding a new route… (a reroute taking over a second) | paused for .rerouting, "Finding a new route…" | "Finding a new route…" |
| The new route | the new manoeuvres, and an alert "New route", "2 min longer" for 6 s, once | the new manoeuvres, and an alert (car API 5; a toast before) for 6 s, once |
| Can't find a route (two tries failed) | paused for .proceedToRoute (no spinner), "Can't find a route. Check your connection", and an alert with Retry | "Can't find a route", "Check your connection", and Retry beside End |
| Offline | paused for .proceedToRoute, "Offline. New route when you're back online" | "Offline", "New route when you're back online" |
Retry needs the app: set onRetryReroute (Swift AtlasCarPlay, Kotlin AtlasCar) to call your
navigation's retryReroute(). Without it, the failure shows with no Retry, and the session keeps trying by
itself. The React Native and Flutter plugins take Retry themselves, unless the app's configure says
showsRetry: false.
No flicker. The card changes only when what it shows changes:
- The "then" manoeuvre shown with the next one stays with it until that manoeuvre is done. It used to come and go with the car's speed, so slowing for a turn dropped it and reset CarPlay's card.
- CarPlay's manoeuvre state (continue, prepare, execute) only moves forward for a manoeuvre; slowing shortened the distances, which used to step it back.
- Estimates go to CarPlay, and Android Auto's template is rebuilt, only when the distance or time as the car shows it changes (a tenth of a mile, ten yards, a minute), not on every fix.
- Android Auto's pictures are drawn once a manoeuvre and kept, not drawn again for every update.
- A short GPS gap or a quick reroute doesn't pause and resume the trip (the status holds through it).
Measured on a simulated 2.7-minute town drive at up to 50 mph with six turns, two pairs close together
(sdk/swift/Tests/MeridianAtlasTests/CarPlayFlickerTests.swift and
native/android/sdk/src/test/kotlin/dev/meridianatlas/android/AtlasCarFlickerTest.kt, the session's own
updates, a fix and a tick a second, with 6 m GPS noise):
| Before | After | |
|---|---|---|
CarPlay: the card set again (upcomingManeuvers) | 15 (5.5 a minute) | 9 (3.3 a minute); 7 (2.6) with "then" only within 6 s |
| CarPlay: estimates sent | 321 (118 a minute) | 144 (53 a minute); 95 (35) with the distances as the phone rounds them |
| CarPlay: pauses and resumes | 1 and 1 (the start) | 1 and 1 |
| Android Auto: template rebuilt | 159 (58.5 a minute) | 94 (34.6 a minute), each one a visible change; 92 (33.9) with "then" only within 6 s |
Phone banner: the card drawn again (ui/guidance-banner.ts bannerChange, 10 updates a second) | 600 a minute | 1.2 a minute, and the distance text 22 a minute |
Speed limits and cameras
The car screens follow the same rules as the phone's panels (the SDK guide,
conformance/speed-alerts-v1.json):
- The sign is a road sign in the map's lower corner: white disc, regulatory red ring, the limit in black. Hidden where the limit isn't known. In km/h a UK 30 limit reads 48, as on the phone (it used to read a 50 that isn't the limit).
- Over the limit, once it has held for a second, the speed shows beside the sign in Meridian's danger colour
(#E8445A); it goes two seconds after the speed is back within the limit, or at once when the limit goes up.
Nothing flashes, and the sign itself stays a sign.
speedTolerance(0 to 10, 0 by default: SwiftAtlasCarPlay.Options, KotlinAtlasCar,AtlasCarScreen.configure, the presentation's unless you give one) is how far over the shown limit before it shows. - A lower limit ahead shows as a small sign with how far ("30 · 60 yd") in a small navy pill beside the sign, 12 seconds before the change at the car's speed.
- Free drive gets the sign and over the limit too, from the road's limit where the car is.
- The sign is drawn on the map, not in a template: its changes don't rebuild Android Auto's template or touch CarPlay's guidance card.
- A speed camera comes from the car screen's own map, warned of at the same distance as on the phone, and shows beside the sign: a camera and how far ("250 yd", then "100 yd") in the same small navy pill as a lower limit ahead, which waits until the camera is passed. The sign above it is the limit the camera enforces. It used to be CarPlay's alert panel ("Speed camera ahead", "In 250 yards · 30 mph limit"), which took most of the left half of the Simulator's car screen under the guidance card; the pill is 30 points tall and under 80 wide, beside the 44-point sign, with nothing above it. An average speed check is warned of at its first camera; a red light camera shows without a limit.
- The car's own alert, short ("Speed camera", "30 mph limit") and gone after 6 seconds, only when the map isn't in front (the rules above): over another app CarPlay shows it as a notification, and a navigation app's alerts reach Android Auto in the background too.
- The app hears it (
onSpeedAlertonAtlasCarPlayandAtlasCar, thespeed_alertevent on React Native's and Flutter'sAtlasCarScreen), and the car screen'svoicesays each camera ("Speed camera ahead, 30 limit") once, even when the phone's map warned of it too, and plays the optional over-limit chime. The car plays both through its speakers with the app's speech; Atlas takes no audio focus and leaves the audio session as the app set it.
docs/sdk/screenshots/speed-alerts-carplay-sign-2026-12-02.png shows CarPlay's sign in each state, drawn at a car
screen's 2× by the iOS app target's CarPlaySpeedSignTests, and carplay-camera-beside-sign-2026-12-03.png and
carplay-camera-beside-sign-over-night-2026-12-03.png the camera beside it (by day; over the limit at night).
Multi-stop trips
Show the car screen a trip from AtlasMultiStop (Swift show(_:stopNames:), Kotlin show(route, stopNames), React
Native and Flutter showTrip) and it guides to each stop in turn:
- The trip estimates are to the next stop: its arrival time, the time and the distance left, at its own leg's driving time from the service (each stop gets its leg's time; time spent at the stops isn't counted). The card names a stop as it comes ("Arrive at Hambleton Bakery").
- At a stop on the way the card says so and names the next, with its arrival time: "Arrived at Hambleton Bakery.
Next: St Mary's at 14:32". The existing arrival handling stays: guidance to the next stop starts when the car drives
on (the session's
leg_started), and the trip ends at the last. - Stops, beside End in the navigation bar (CarPlay) or the action strip (Android Auto), opens the stops still to come, the next first, each with its arrival time and distance ("Arrive 14:32 · 0.4 mi"): CarPlay's list template, Android Auto's list. The map's card doesn't grow for it; Back (or Skip) returns to the map.
- "Skip this stop" for the next stop, under it in the list, once your app takes it. It doesn't change the trip:
it tells your app which stop (
onSkipStop, or the plugins'skip_stopevent), and your app decides, usually by routing the rest of the trip without it (AtlasMultiStop), beginning navigation along that and showing it here. The last stop is never offered; End is the way out there. - The instrument cluster (Android Auto) gets each stop to come with its own arrival; CarPlay has no place for stops on the way beyond the trip's estimates, so it gets the next stop's.
carPlay.onSkipStop = { stopId in skipStop(stopId) } // your app decides; nil (the default) offers no Skip
carPlay.showStops() // the list from your own button too (the car screen's Stops does the same)car.onSkipStop = { stopId -> skipStop(stopId) } // your app decides; null (the default) offers no Skip
car.showStops() // the list from your own button too (the car screen's Stops does the same)car.onSkipStop((stopId) => skipStop(stopId)); // turns Skip on; your app decides
await car.showStops(); // the list from your own button too (the car screen's Stops does the same)await car.setSkipStopsEnabled(true); // your app decides
car.onSkipStop.listen(skipStop);
await car.showStops(); // the list from your own button too (the car screen's Stops does the same)Day and night
The car screen is dark when the car says, usually with its headlights, whatever the phone's map does (unless your app holds day or night: below):
- CarPlay: the car's content style (
CPTemplateApplicationScene.contentStylewhen it connects, thencontentStyleDidChange, which the ready-made scene delegates pass on; the car window's appearance says so too). The car screen's, dashboard's and instrument cluster's maps switch together, with the ground behind them and the trip estimates (CPMapTemplate.tripEstimateStyle). The guidance card keeps its colour (Meridian navy unless yours): it reads on a day map and stands off a night one, and CarPlay picks its text and the symbols' dark variant by it. The speed limit sign stays a white disc, as on the road. - Android Auto:
CarContext.isDarkMode, and the session'sonCarConfigurationChangedwhen it changes. The map, the ground behind it and the templates switch together; the map buttons' and the camera alert's icons are tinted by Android Auto (CarColor.DEFAULT) to read on its light and dark controls.
The map switches in place, as on the phone: no reload, and the route and camera stay as they were. Each loads on the same day ground or night surface as the phone's map view. With the car connected, the phone and the car may differ for a while at dusk (the phone goes by the sun or its own dark mode, the car by its light sensor): each is consistent in itself.
Holding day or night, one line. The car screen's appearance is auto by default: it follows the car
(system does too). Set day or night to hold it there whatever the car says (a setting in your app),
and auto to give it back to the car. At any time, guiding or not, before the car connects or after (the
plugins keep it across configure). Everything above switches together, in place. The phone's own map is
set apart (Day and night).
carPlay.appearance = .night // CarPlay at night, whatever the car says
carPlay.appearance = .auto // the car's own againcar.appearance = AtlasMapAppearance.NIGHT // Android Auto at night, whatever the car says
car.appearance = AtlasMapAppearance.AUTO // the car's own againawait car.setAppearance("night"); // CarPlay or Android Auto at night, whatever the car says
await car.setAppearance("auto"); // the car's own againawait car.setAppearance(AtlasMapAppearance.night); // CarPlay or Android Auto at night, whatever the car says
await car.setAppearance(AtlasMapAppearance.auto); // the car's own againThe wording
Each manoeuvre's forms, most to least verbose, for "At the roundabout, take the third exit onto East Lancashire Road (A580)":
| Form | Text |
|---|---|
| The route's wording, as car screens print it | At the roundabout, take the 3rd exit onto East Lancashire Rd (A580) |
| The road, with its number | 3rd exit, A580 East Lancashire Rd |
| The road's name | 3rd exit, East Lancashire Rd |
| Its number | 3rd exit, A580 |
| What to do | Take the 3rd exit |
A turn has the same forms without the exit ("A56 Deansgate", "Deansgate", "A56", "Turn left"). CarPlay's card leads with the longest that fits one line at the car screen's width (CarPlay would wrap a longer one onto a second line, making the card taller); Android Auto shows the first that fits. The dashboard and instrument cluster get the same forms, and the road following the manoeuvre ("A580 East Lancashire Rd").
- Abbreviations: only the word that ends a road's name, as Royal Mail and UK car screens write it (St, Rd, Ave, Ln, Dr, Pl, Sq, Cres, Cl, Ct, Gdns, Gr, Terr, Pde): "Booth St", "Whitworth St West", "Booth St car park". Never a name's first word ("Street Lane" is "Street Ln"), a word inside a name ("Hanger Lane Gyratory"), one after "The" ("The Street"), "Saint", or a place on a sign ("towards Liverpool Street Station"). A name in capitals keeps them ("LONDON RD").
- Road numbers are never split or shortened: "A57(M)", "M6 Toll", "A1(M) J6". One road with two numbers ("B5158;B5214" in the map data) reads "B5158/B5214".
- Welsh and English names: of a name given twice ("Heol y Frenhines / Queen Street"), the shorter forms keep the one the route gives first, with the number ("A4161 Heol y Frenhines").
- Long names: the number when the road has one ("A6046" for "Lance Corporal Stephen Shaw M.C. Way"). Only when nothing naming the road fits, the name cut between words with an ellipsis, to about 32 and 20 characters ("Ffordd Cyswllt Ystad…", "Ffordd Cyswllt…"), and never to less than 8 characters.
- Roundabouts: the road out, never the roundabout's own name ("Hole House Roundabout").
- The voice says everything in full ("Street", "junction 19", "the A five-eighty", "the M six Toll"), and the road's number after its name when the step's road fields give it and its wording doesn't: "Turn left onto Deansgate, the A fifty-six", as a roundabout's "onto Regent Road, the A fifty-seven".
conformance/road-name-wording-v1.json holds real UK names (and every road on 29 real routes) with what
CarPlay, Android Auto, the phone banner and the voice make of each; all four are tested against it, and each
SDK runs its entries through its own routes client and the map's and car screen's route.
Where the road and its number come from. Every SDK hands the car screen, and the map, each step's
wording, exit number and sign, and the road it leads onto: its name and numbers as the routing service sends
them (roadName and roadRef, map-host-wire-v1; your app reads them as roadName and roadNumbers). So a
turn's card reads "A56 Deansgate" (the number alone, "A56", where nothing longer fits), not "Deansgate" alone,
and a roundabout's "2nd exit, B5117 Booth St". From an older service, whose steps carry no road fields, a turn's number shows
only where the wording carries it (a roundabout's "East Lancashire Road (A580)" does; "Turn left onto
Deansgate" doesn't), and the voice says the wording alone: the corpus's withoutRoadFields forms.
| From a service with road fields | From an older service | |
|---|---|---|
| CarPlay card, a 20-character line | A56 Deansgate | Deansgate |
| Android Auto, the forms in order | Turn left onto Deansgate, A56 Deansgate, Deansgate, A56, Turn left | Turn left onto Deansgate, Deansgate, Turn left |
| The phone banner | Turn left · A56 Deansgate (the number a sign patch) | Turn left · Deansgate |
| The voice | Turn left onto Deansgate, the A fifty-six | Turn left onto Deansgate |
Spoken guidance. The car screen shows guidance but says nothing unless you give it a voice:
- Swift and Kotlin: set
voice(anAtlasVoice) onAtlasCarPlayorAtlasCar. Each update you pass it then has its announcements said, and they stop when guidance ends. CarPlay and Android Auto play the app's navigation speech through the car. - Handing an update to the same voice yourself as well does no harm: an announcement already being said is said once.
- React Native and Flutter: set
car.voice(anAtlasVoice: the device voice or your own output) onAtlasCarScreen. It hears the module's own session, as the car screen does, so each update's announcements are said, the car screen's cameras and chime too, and it stops when your app callsendGuidance(). The speech reaches the car the same way.
iOS: CarPlay
What Apple needs
CarPlay apps need Apple's CarPlay navigation entitlement (com.apple.developer.carplay-maps). Apple
grants it per app: request it from Apple for your bundle ID, then use a provisioning profile that includes
it. The iOS Simulator's CarPlay window works without it, so you can build and test first.
Info.plist
Add the CarPlay scene, and the dashboard's and instrument cluster's if you want maps there, to your scene manifest. Each is connected for you by a ready-made scene delegate.
| Scene role | Scene class | Delegate (Swift package) | Delegate (React Native, Flutter) |
|---|---|---|---|
CPTemplateApplicationSceneSessionRoleApplication | CPTemplateApplicationScene | AtlasCarPlaySceneDelegate | MeridianAtlasCarPlaySceneDelegate |
CPTemplateApplicationDashboardSceneSessionRoleApplication | CPTemplateApplicationDashboardScene | AtlasCarPlayDashboardSceneDelegate | MeridianAtlasCarPlayDashboardSceneDelegate |
CPTemplateApplicationInstrumentClusterSceneSessionRoleApplication | CPTemplateApplicationInstrumentClusterScene | AtlasCarPlayInstrumentClusterSceneDelegate | MeridianAtlasCarPlayInstrumentClusterSceneDelegate |
The dashboard also needs CPSupportsDashboardNavigationScene, and the instrument cluster
CPSupportsInstrumentClusterNavigationScene (both YES). Add the location background mode
(UIBackgroundModes) so guidance carries on with the phone locked.
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<true/>
<key>UISceneConfigurations</key>
<dict>
<key>CPTemplateApplicationSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>CarPlay</string>
<key>UISceneClassName</key>
<string>CPTemplateApplicationScene</string>
<key>UISceneDelegateClassName</key>
<string>AtlasCarPlaySceneDelegate</string>
</dict>
</array>
</dict>
</dict>To add templates of your own (a destination search, say), write your own CarPlay scene delegate and call
carPlay.connect(interfaceController, window:) from it. Then push your templates through
carPlay.interfaceController, and put your buttons in carPlay.leadingNavigationBarButtons.
Swift
Make one AtlasCarPlay when the app starts. The ready-made delegates connect AtlasCarPlay.shared, the
one made last.
let carPlay = AtlasCarPlay(configuration: atlas)
carPlay.onStartTrip = { trip in
// The driver chose a route on the car screen: begin navigation along it, then show it.
if case .route(let route) = trip { _ = try? navigation.begin(route.plan); carPlay.show(route) }
}
carPlay.onEndGuidance = { _ = try? navigation.stop() }
carPlay.onRetryReroute = { navigation.retryReroute() } // Retry on "Can't find a route"
carPlay.previewRoutes([quickest, shortest], destinationName: "Interact CC Wigan", destination: wigan)
// In your AtlasNavigation's onUpdate (any thread). After a reroute, show the new route first (the session
// reroutes by itself; route_replaced brings the new route), so the update and its "New route" are for it:
for effect in update.effects where effect.type == "route_replaced" { if let route = effect.route { carPlay.show(route) } }
carPlay.update(update)The pieces:
- A multi-stop trip:
previewTrip(route, stopNames:)andshow(route, stopNames:);onSkipStopandshowStops()(Multi-stop trips). - Free drive:
show(position:), thenupdate(freeDriveSnapshot). - The look:
AtlasCarPlay.Optionssets:- the guidance card's colour;
- the car screen's map presentation;
- the dashboard's and cluster's map presentations (2D at low quality unless you say);
- the speed limit sign.
samples/ios-carplay is a working app: Sources/Drive.swift is everything it does for CarPlay.
React Native and Flutter
The plugins' native code holds the car screen. Configure it once, preview and show routes, and listen for the driver's choice:
import { NativeModules, NativeEventEmitter } from "react-native";
import { AtlasCarScreen } from "@meridianatlas/react-native";
const car = new AtlasCarScreen(NativeModules.MeridianAtlas, NativeEventEmitter);
await car.configure({ configuration: atlas });
car.onEvent((event) => {
if (event.type === "start_trip") startGuidance(routes.find((route) => route.routeId === event.routeId));
if (event.type === "end_guidance") navigation.stop();
});
await car.previewRoutes([quickest, shortest], { destinationName: "Interact CC Wigan" });
await car.showRoute(route); // when navigation begins, and after each reroutefinal car = AtlasCarScreen();
await car.configure(configuration: atlas);
car.events.listen((event) {
if (event is AtlasCarStartTrip) startGuidance(routes.firstWhere((route) => route.routeId == event.routeId));
if (event is AtlasCarEndGuidance) navigation.stop();
});
await car.previewRoutes([quickest, shortest], destinationName: 'Interact CC Wigan');
await car.showRoute(route); // when navigation begins, and after each rerouteThe same calls drive Android Auto on Android.
Android: Android Auto
Android Auto uses the Car App Library's navigation templates (androidx.car.app). Add it to your app: the
Atlas SDK compiles against it without bringing it, so apps without Android Auto don't carry it.
dependencies {
implementation("androidx.car.app:app:1.7.0")
}Manifest
Declare the car app service with the navigation category and the car app metadata. The minimum Car App API level is 1 for the template; the car's own camera alert (when the map isn't in front) uses car API level 5, and a short toast before it, and the Stops list sizes itself to the host's list limit from car API level 2.
<uses-permission android:name="androidx.car.app.NAVIGATION_TEMPLATES" />
<uses-permission android:name="androidx.car.app.ACCESS_SURFACE" />
<application>
<meta-data android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<meta-data android:name="androidx.car.app.minCarApiLevel" android:value="1" />
<service android:name=".NavigationCarAppService" android:exported="true">
<intent-filter>
<action android:name="androidx.car.app.CarAppService" />
<category android:name="androidx.car.app.category.NAVIGATION" />
</intent-filter>
</service>
</application>res/xml/automotive_app_desc.xml:
<automotiveApp>
<uses name="template" />
</automotiveApp>React Native and Flutter apps name the plugin's service instead of their own:
dev.meridianatlas.android.car.MeridianAtlasCarAppService.
- Debug builds accept any Android Auto host.
- Release builds accept the hosts in the Car App Library's allow-list. To name your own list, add
meta-data
dev.meridianatlas.car.hosts(an array resource) to the service.
Kotlin
val car = AtlasCar(configuration)
car.onStartTrip = { trip -> /* begin navigation along it, then car.show(route) */ }
car.onEndGuidance = { navigation.stop() }
car.onRetryReroute = { navigation.retryReroute() } // Retry on "Can't find a route"
car.previewRoutes(listOf(quickest, shortest), destinationName = "Interact CC Wigan")
// In your AtlasNavigationListener.onUpdate:
car.update(update)
class NavigationCarAppService : CarAppService() {
override fun createHostValidator() =
if (BuildConfig.DEBUG) HostValidator.ALLOW_ALL_HOSTS_VALIDATOR
else HostValidator.Builder(this).addAllowedHosts(androidx.car.app.R.array.hosts_allowlist_sample).build()
override fun onCreateSession() = (application as App).car.createSession()
}How the map gets onto the car's surface:
- The map: the Atlas map is a WebView. It draws on the surface Android Auto gives the app, through a
Presentationon a virtual display. It logs its frame rate under the tagAtlasCar. - Insets: the car's visible area keeps the car out from under the guidance card.
- Gestures: pans and pinches move the map.
- Your own screens: to build your own car screens around the map, use
car.controller. ItssurfaceCallback(context)is the map surface.
Android Automotive OS
Android Automotive OS (the car's own Android, no phone) runs Car App Library navigation apps too. It needs:
- the
androidx.car.app:app-automotiveartifact; - a separate APK or module with the automotive features declared;
- the WebView, which is available on Android Automotive OS but not certified on every car.
It isn't part of this release.
Simulated drives (testing and app review)
AtlasRouteSimulator drives your navigation session along a route without moving:
- at 1 to 10 times real speed;
- keeping to the speed limits and slowing for turns;
- with optional GPS noise of a chosen accuracy (seeded, so a run repeats).
It can also replay a recorded drive trace (conformance/navigation-drive-traces-v1.json's fix events).
While it runs, the session takes only its fixes.
It is a developer's and a reviewer's tool, off by default. Turn it on only in debug builds and builds for app review, and in a debug build only when you are testing a drive (a launch argument, a debug setting), so the app otherwise looks as it will in the store:
#if DEBUG || ATLAS_REVIEW
let simulator = AtlasRouteSimulator(navigation: navigation, speedMultiplier: 4)
carPlay.simulator = simulator // a Simulate button on the car screen while guiding
map.simulator = simulator // Simulate drive on the phone's map, beside its buttons
#endifif (BuildConfig.DEBUG || BuildConfig.ATLAS_REVIEW) {
val simulator = AtlasRouteSimulator(navigation, speedMultiplier = 4.0)
car.simulator = simulator // a Simulate action on the car screen, and Android Auto's AUTO_DRIVE
map.simulator = simulator // Simulate drive on the phone's map, beside its buttons
}React Native and Flutter:
- The drive:
AtlasRouteSimulator(start,replay,stop). - The car screen's button:
car.setSimulationEnabled(true). - The phone's map: React Native's
simulationEnabledprop, Flutter'smap.setSimulationEnabled(true).
The phone's Simulate drive is on the map's own panels (the SDK guide), so an app needs no panel of its own for it, and nothing of it is left to show in production: the trip panel stays at the bottom of the screen, with End.
For Google Play's reviewers
Google Play reviews navigation apps for Android Auto, and its reviewers must be able to drive a route
without moving. Build the review build with the simulator on (ATLAS_REVIEW), and tell them how in the
Play Console's app access instructions. For example:
Choose a destination and start navigation. On the car screen, tap Simulate
(or run: adb shell dumpsys activity service com.example.app/.NavigationCarAppService AUTO_DRIVE).
The car drives the route at 4x speed; tap Stop drive to stop.The AUTO_DRIVE command is Android Auto's own test hook. Atlas answers it with the simulated drive when a
simulator is set.
Testing
- CarPlay: open the iOS Simulator's CarPlay window (I/O > External Displays > CarPlay) with your
app running. Test in a car, or on an aftermarket CarPlay unit, before release (
docs/CARPLAY_TEST_PLAN.md). - Android Auto: use the Desktop Head Unit from the Android SDK (
extras/google/auto/desktop-head-unit). The phone or emulator needs the full Android Auto app, with its head unit server started from Android Auto's developer settings. Then runadb forward tcp:5277 tcp:5277and start the head unit. Local testing needs no approval from Google. - The samples: both use a local demo service with fixed routes through Manchester. Run
npm run build, thennode scripts/carplay_demo_server.mjs(port 4310).- iOS:
samples/ios-carplay(its README). - Android: the SDK sample's debug build has an Android Auto demo (
native/android/sdk/sample/src/debug,CarDemo.kt). Run./gradlew :sample:installDebuginnative/android/sdk, thenadb reverse tcp:4310 tcp:4310, then start the head unit. Choose a route and tap Go: the drive is simulated, and Stop drive and Simulate stop and restart it.
- iOS:
- The car map off the car:
native/android/map-perf'sCarSurfaceActivitydraws Android Auto's map surface into an image reader at a car screen's size, along a demo route. It counts the frames that reach the surface.