React Native quickstart
Get a key
In Atlas Studio, create an app key with these features: Routes
(core_routing), Navigation (navigation) and Maps (map_tiles).
Add your iOS bundle ID, your Android package name and the SHA-256 of each
certificate that signs the Android app (cd android && ./gradlew signingReport; the debug and release builds are signed differently, so list
both). The secret is shown once: keep it out of source control. Studio's code
sample needs only the key: the configuration defaults to the Atlas service and
map viewer (below).
Install
npm install ./meridianatlas-react-native-0.1.0-rc.6.tgz # the release archive, in your app
cd ios && pod installIt needs iOS 15.1 and Android 8.0 (API 26) or later. New React Native apps start
at API 24, so set minSdkVersion = 26 in android/build.gradle.
The package includes its native module (MeridianAtlas, autolinked; run
pod install on iOS), with the Atlas native core, which runs GPS itself while a
session is active. Create the bridges once:
import { NativeModules, NativeEventEmitter } from "react-native";
import { createAtlasNativeBridges } from "@meridianatlas/react-native";
const bridges = createAtlasNativeBridges(NativeModules.MeridianAtlas, NativeEventEmitter);
// bridges.navigation -> AtlasNavigation, bridges.freeDrive -> AtlasFreeDrive,
// bridges.offline -> AtlasOfflineRoutesYour app asks for location permission: on iOS NSLocationWhenInUseUsageDescription
in Info.plist (plus the location background mode for guidance with the
screen locked) and Core Location's requestWhenInUseAuthorization() (the
module never asks); on Android request ACCESS_FINE_LOCATION and
ACCESS_COARSE_LOCATION together at runtime with PermissionsAndroid (the
module declares both; Android 12 and later ignore a request for fine alone),
and POST_NOTIFICATIONS on Android 13+ for the "Navigating"
notification of the foreground service that keeps guidance going with the
screen off. The example app (example-app/App.tsx) does both, and says what
to do when location is off or only approximate. begin() without location permission fails with AtlasNavigationError code
location_permission_required, and with only approximate location
location_accuracy_reduced (too coarse to navigate by), on iOS and Android,
each with a message saying what to ask for.
Made with the configuration, the session reroutes by itself (see
Rerouting). Call setConnectivity(false) when the app goes
offline, and reroutes wait instead.
Configure the key
Make one configuration and give it to every client:
import { NativeModules } from "react-native";
import { AtlasNavigation, AtlasRoutes, atlasAppIdentity, atlasConfiguration } from "@meridianatlas/react-native";
const atlas = atlasConfiguration({
apiKey,
appIdentity: atlasAppIdentity(NativeModules.MeridianAtlas),
});
const routes = new AtlasRoutes(atlas);
const navigation = new AtlasNavigation(bridges.navigation, atlas); // reroutes and registers its legs itself
// AtlasMultiStop, AtlasRouteMatrix, AtlasPlaces, AtlasTraffic, AtlasNavigationLegs and AtlasRoads too;
// the map: <AtlasMapView configuration={atlas} ... /> (the viewer gets the key)The configuration defaults to the Atlas service at https://api.meridianatlas.dev and the map
viewer at https://maps.meridianatlas.dev/v1, so this needs only your key. That domain
isn't live yet: until it is, beta partners pass the two addresses Meridian gave them:
const atlas = atlasConfiguration({
apiKey,
baseUrl: "https://your-atlas-host",
viewerUrl: "https://your-atlas-viewer",
appIdentity: atlasAppIdentity(NativeModules.MeridianAtlas),
});(ATLAS_DEFAULT_BASE_URL and ATLAS_DEFAULT_VIEWER_URL name the defaults.) URLs must use HTTPS;
plain HTTP works only in a development build (__DEV__), to this device
(localhost, 127.0.0.1) or the Android emulator's host (10.0.2.2).
timeoutMs (default 30000) applies to each request. atlasAppIdentity reads
your app's identity from the native module, once: the bundle ID on iOS, the
package name and the SHA-256 of its signing certificate on Android. Every
request sends it (Atlas-App, Atlas-App-Cert), so an app key made in Atlas
Studio for your app works; an app key used from an app it doesn't list fails
with app_not_allowed. Leave appIdentity out to send none (server keys
don't need it). The older constructors, new AtlasRoutes(baseUrl, apiKey) and
the rest, still work but send no app, so an app key refuses them with
app_not_allowed: every sample below takes the configuration. On Android a
development build also needs cleartext allowed for a plain-HTTP host (React
Native's Gradle plugin allows it in debug builds of a standard app).
Getting a route
import { AtlasRoutes } from "@meridianatlas/react-native";
const routes = new AtlasRoutes(atlas); // atlas: from "Configure the key"
const route = await routes.route({ origin: [-2.2511, 53.4747], destination: [-2.246, 53.4837] });
// route.guidance: the steps to show and speak; route.plan: what navigation.begin() takes
// route.speedSections: the speed limits along itAdd departureTime: "2026-12-01T08:00:00Z" (ISO 8601) to plan a later
journey, traffic: "aware" to allow for traffic, and approach: "curb" to
arrive with the destination on the driver's side of the road (the left in the
UK). The route's plan keeps these (route.plan.options), so its reroutes are
asked for the same way. A failure is an
AtlasError (see Errors); route_unresolved means there is no
route between those points.
Offline routes
With an offline package downloaded and activated, route on the device instead:
import { AtlasOfflineRoutes } from "@meridianatlas/react-native";
const offline = new AtlasOfflineRoutes(bridges.offline);
await offline.initialize(); // fails closed if the native module's contract differs
await offline.open({
routingPath: `${packageFolder}/routing.bin`,
waysPath: `${packageFolder}/ways.bin`, // road names for the instructions
releaseId: manifest.releaseId,
});
const route = await offline.route({ origin: [-2.2511, 53.4747], destination: [-2.246, 53.4837] });
await navigation.begin(route.plan); // the same AtlasRoute as onlinepackageFolder is wherever your package persistence installed it. Routing runs
off the main thread in the native module, and reroute(effect) works as
online. Errors are AtlasError with the online codes (route_unresolved
when the points are outside the package or don't meet a road) plus
offline_package_unreadable and offline_package_invalid. Lanes aren't in
offline packages, so offline steps have no lane guidance.
Installing a package is iOS and Android only for now. A JavaScript download and
install API is in @meridianatlas/react-native/experimental-offline: it isn't
finished and may change in any release, and its failures are
AtlasOfflineDownloadError with a code.
Route guidance
import { AtlasNavigation, decodeGuidanceStep } from "@meridianatlas/react-native";
const navigation = new AtlasNavigation(bridges.navigation, atlas);
await navigation.initialize(); // fails closed if the native contract differs
navigation.subscribe((update) => {
for (const effect of update.effects) {
// The session rerouted: show the new route, and guide by its steps from now on.
if (effect.type === "route_replaced" && effect.route) showRoute(effect.route);
if (effect.type === "pause_guidance") showStatus("Waiting for GPS");
if (effect.type === "arrived") showStatus("You have arrived");
}
});
await navigation.begin(route.plan); // the AtlasRoute from routes.route(...)Each step in route.guidance has an instruction ready to show and speak
("At the traffic lights, turn right onto Booth Street"), with lanes, signposts
and landmark. Through a tunnel progress is estimated from the last speed and
update.snapshot.positionEstimated is true: show the position as estimated.
Rerouting
Made with a configuration, the session reroutes by itself. When the car leaves
the route, it fetches a new one: from where the car is, facing the way it is
going, to the destination (on a multi-stop route, the next stop not yet
reached), asked the way the route was (its plan's options: profile, traffic,
side of the road, and a departure time moved on by the time guidance has run).
Guidance keeps the old route until the new one arrives. Your app only shows the
new route: route_replaced carries it as effect.route.
It doesn't reroute a car crawling off the route (a car park, a forecourt, a queue) unless it has turned round. For apps that show what is happening, the updates say:
request_reroute: a route is being fetched (phaseisrerouting).route_replaced: the new route is in use (effect.route).reroute_failed: the fetch failed (reasonis the error's code, orno_answerafter 20 seconds). The old route is kept, and the session asks again atretryAtMs: after 3 seconds, then 6, 12 and so on, up to a minute.reroute_cancelled: the car came back to the route (reasonisback_on_route), so the fetch was dropped.reroute_deferred: no connection (offline), or waiting before asking again (backoff).
Answering reroutes yourself
Pass rerouting to use your own routing:
// Your routing, run as automatic rerouting is: one fetch at a time, dropped when no longer needed.
const custom = new AtlasNavigation(bridges.navigation, atlas, undefined, {
rerouting: (effect) => yourRouter.route(effect.origin!, effect.destination!, effect.headingDegrees ?? null),
});
// Or answer each request_reroute yourself.
const manual = new AtlasNavigation(bridges.navigation, atlas, undefined, { rerouting: "manual" });
await manual.initialize();
manual.subscribe((update) => {
for (const effect of update.effects)
if (effect.type === "request_reroute" && effect.requestId) {
const { requestId } = effect;
void yourRouter.route(effect.origin!, effect.destination!, effect.headingDegrees ?? null)
.then((plan) => manual.completeReroute(requestId, plan), (error) => manual.failReroute(requestId, error));
}
});With "manual", and without a configuration (new AtlasNavigation(bridges.navigation)),
answer every request_reroute: completeReroute(requestId, plan) with the new
route (routes.reroute(effect) fetches it), or failReroute(requestId, error)
when the fetch failed. The session keeps the old route and asks again. A
request left unanswered for 20 seconds counts as failed.
Navigation legs
Turn-by-turn guidance is charged per leg: one leg is guidance to one
destination, and the reroutes on the way are included (the key needs the
navigation feature). Made with the configuration, the session does this
itself:
const navigation = new AtlasNavigation(bridges.navigation, atlas);
await navigation.initialize();
navigation.subscribe((update) => { /* as in "Route guidance" */ }, (error) => {
// leg_registration_failed: guidance carries on; leg_invalid (50 reroutes, or the leg refused): reroutes go on without it
if (error.code === "leg_registration_failed" || error.code === "leg_invalid") console.warn(error.message);
});
await navigation.begin(route.plan); // registers the leg to the route's end, in the background
await navigation.stop(); // ends the leg (on arrival it ends itself)beginregisters the leg in the background; guidance never waits for it. Beginning again to the same destination (within 50 m) keeps the leg; a new destination ends it and starts another.navigation.legIdis the leg, once registered.- Each
request_rerouteeffect carrieslegId, and the session's reroutes send it (so doesroutes.reroute(effect), if you answer yourself), so a reroute costs nothing more. A leg includes 50 reroutes: after that, or if the service refuses the leg, the session reroutes without it, charged as a route, andonErrorgetsleg_invalidonce. A reroute asked for before the leg is registered goes without one, and is charged as a route. - A failure that may pass (no connection, a timeout,
rate_limit, a 5xx) is tried again after 1, 2, 4, 8 and 16 seconds, with the sameIdempotency-Key, so the leg is charged once. If it still can't be registered (or the key is refused),subscribe'sonErrorgets anAtlasNavigationErrorwith codeleg_registration_failed, once; itscauseis the service'sAtlasError(capability,status). Guidance carries on, and its reroutes are charged as routes. - Arrival ends the leg (
arrived), and so doesstop()(cancelled). - A third argument,
transport, is for tests or your own networking.
Without a configuration the session contacts no server; do the same by hand:
import { AtlasNavigationLegs } from "@meridianatlas/react-native";
const legs = new AtlasNavigationLegs(atlas);
const leg = await legs.start(route.coordinates[route.coordinates.length - 1]!); // when guidance starts
const replacement = await routes.reroute(effect, { legId: leg.legId }); // on request_reroute: included in the leg
await legs.end(leg.legId, "arrived"); // on arrival ("cancelled" when the driver stops)Pass reroute the original route's options too
({ ...route.plan.options, legId: leg.legId }) to keep them. A reroute must keep
the leg's destination (within 50 m): a new destination is a new leg, and so is
each stop of a multi-stop route (the session does this itself, see
Multi-stop routes; by hand, start one with the stop's point
on the route when the driver sets off for it). A leg
lasts 24 hours. A reroute with a leg that has ended or expired fails with
leg_invalid, and one to somewhere else with leg_destination_mismatch: start
a new leg. Asking again for the same request_reroute after a timeout or lost
connection reuses its Idempotency-Key, so a request that did reach the
service counts once.
Showing the map
The package registers a native map view on iOS and Android: the Atlas 3D map,
from the Atlas viewer at the configuration's viewerUrl (no web-view package
needed). The viewer gets the configuration's key for its scenery, in the page,
never in its URL. Pass it the route and the latest snapshot; the car moves with
each snapshot, estimated progress through a tunnel included:
import { requireNativeComponent } from "react-native";
import { ATLAS_MAP_VIEW, atlasMapPresentation, atlasMapRoute, type AtlasMapViewProps } from "@meridianatlas/react-native";
const AtlasMapView = requireNativeComponent<AtlasMapViewProps>(ATLAS_MAP_VIEW);
// route: the AtlasRoute whose plan you began; snapshot: the latest update.snapshot from navigation.subscribe
<AtlasMapView style={{ flex: 1 }} configuration={atlas} route={atlasMapRoute(route)} snapshot={snapshot}
presentation={atlasMapPresentation({ style: "standard", navigationUI: true })}
onMapError={(event) => showStatus(`Map: ${event.nativeEvent.message}`)}
onMapWarning={(event) => setMapNotice(event.nativeEvent.active)} />onMapWarning is a problem the map carries on through
(map_detail_unavailable, context_lost, runtime_error, quality_reduced),
with active true when it starts and false when it clears. A lost graphics context is recovered by
reloading the map, which keeps what it was shown; only if three reloads don't
bring it back does onMapError say context_lost.
atlasMapRoute(route) (for an AtlasRoute or an AtlasMultiStopRoute) gives
the map the route's guidance, so the route line moves into the lane each
junction needs, and its speed limits. route={route.plan} still works and shows
only the line. navigationUI: true shows the built-in Meridian guidance panels
(manoeuvre, lanes, camera alerts, and the speed with the limit, red when over
it); it is off by default, for apps that draw their own. Its banner shows the
route's own words ("At the traffic lights, turn right onto Ormskirk Road"), the
sign at a fork and a roundabout's exit.
The panels also show:
- Trip progress: the arrival time, time left and distance left. On a multi-stop trip they show the next stop ("Stop 2 of 4") and the destination.
- Recentre: the driver can pan and pinch the map, and Recentre brings the camera back to the car, at the camera's own distance, tilt and heading.
- Overview: the whole remaining route (the car, each stop left and the destination), flat and north-up, clear of the panels. Guidance carries on, and Recentre comes back.
- Mute: the voice's mute button.
- The arrival card: at each stop it offers Next stop and End; at the destination, End.
Name the places, and pass the driver's choices on:
<AtlasMapView style={{ flex: 1 }} configuration={atlas} snapshot={snapshot}
route={atlasMapRoute(route, { destination: { name: "Interact CC Wigan", address: "Wallgate, Wigan WN1 1BA" } })}
presentation={atlasMapPresentation({ navigationUI: true })}
deviceVoice // the mute button mutes and unmutes the device voice, new AtlasVoice(bridges.voice)
onArrivalAction={({ nativeEvent }) => { if (nativeEvent.action === "end") navigation.stop(); }} />For a multi-stop trip, name the stops by id: atlasMapRoute(trip, { stops: { tesco: { name: "Tesco Pemberton" } } }).
With deviceVoice, the mute button and the device voice follow each other natively: there is
nothing more to write, and voice.setMuted(true) from your own settings shows on the button. With
a voice of your own output (new AtlasVoice({ speak })), pass the taps on yourself:
onVoiceMutedChanged={({ nativeEvent }) => voice.setMuted(nativeEvent.muted)}.
voiceMuted sets the button from your app's own state; it is applied when it changes. A new
recentreKey and onFollowingChanged do what the recentre button does, for your
own controls; a new overviewKey and onOverviewChanged do the same for the
overview. navigationPanels on atlasMapPresentation turns panels off one
by one (it lists the ones to show; ATLAS_NAVIGATION_PANELS has them all).
Without "recentre", the map doesn't move under the driver's fingers, and the
overview button doesn't show. atlasMapPresentation({ autoRecentreAfterSeconds: 10 })
brings the camera back to the car by itself 10 seconds after the driver last
moved the map or opened the overview (2 to 600 seconds; off by default).
Lay the map out edge to edge (outside any SafeAreaView): the panels keep clear of
the status bar, the Dynamic Island, notch or camera cut-out and the home indicator
or navigation bar by themselves, upright and on its side, and their text follows the
system's text size (up to 1.5 times). If your own views cover part of the map, say
how much at each edge, measured from the map's edges, and the panels and the car keep
clear of them too: insets={{ bottom: sheetHeight }}.
quality sets how much the map spends on each frame: "auto" (the default)
starts from what the device says about itself and steps down a tier when frames
stay slow (a quality_reduced warning); "high", "balanced" and "low" hold
one tier. onMapReady's nativeEvent.quality says which tier the map started at.
A route with a new id (after a reroute) is swapped in place, without reloading
the map. configuration, viewerBaseUrl and presentation are read once, when
the map starts. A viewerBaseUrl you pass is loaded instead of the
configuration's viewerUrl; with neither a configuration nor viewerBaseUrl,
onMapError says invalid_prop. A map with only viewerBaseUrl still works
and sends no key.
In free drive, pass no route, position (the car's first matched point) and
freeDriveSnapshot (the latest free-drive snapshot); the car follows the road
it is matched to, and the map shows the speed limit there.
Speaking the guidance
Atlas decides what to say and when. Any update can carry an announcement in
update.announcements: "In 300 yards, turn left onto Deansgate", then "Turn
left now".
- Where they come from: the route's guidance.
route.plancarries it, so a route fromAtlasRoutesorAtlasMultiStopis announced. A hand-made plan withoutguidanceis guided in silence. - When: warnings come further ahead on faster roads, and close manoeuvres
are joined ("…, then turn left"). Nothing is said while
phaseisn't"on_route", and after a reroute (the session's own, or yours) the new route is announced with nothing said twice. Each stop of a multi-stop route gets its own arrival. - Road numbers: written the way they are said ("the A five-eighty", "junction 19"), so any speech module says them the British way.
To have Atlas speak them, use the opt-in AtlasVoice:
import { AtlasVoice } from "@meridianatlas/react-native";
const voice = new AtlasVoice(bridges.voice); // the device's best British voice
voice.subscribe((event) => {
// will_speak: duck your own audio; did_speak with speaking false: restore it
});
navigation.subscribe((update) => { void voice.handle(update); });- Voices:
await voice.voices({ locale: "en-GB", minimumQuality: "enhanced" })lists the installed voices, best first.- Choose one with
voice.selectVoice(id);voice.preview(undefined, id)says a sample. - iOS's Premium voices, and Google's British voices, may need a download in the phone's settings.
requestPersonalVoice()asks to use the user's own Personal Voice (iOS 17 and later).
- Audio stays yours: AtlasVoice never configures the audio session or
requests audio focus. On iOS, add the
audiobackground mode to speak with the screen locked. - Rules: a more urgent announcement cuts the current one short, and a less
urgent one waits for it. A pause drops whatever was waiting. Also
setMuted()andstop(). - Your own voice:
new AtlasVoice({ speak: (text, ssml) => myTts(text) }), for exampleexpo-speechor a cloud neural voice.speakresolves when the prompt has been said. Or skip AtlasVoice and speak each announcement'stextyourself.
Testing in the simulator and emulator
The module runs GPS itself, so give the simulator or emulator a drive:
- iOS Simulator:
xcrun simctl privacy booted grant location <your bundle ID>, thenxcrun simctl location booted start --speed=12 53.47475,-2.25165 53.47983,-2.24868 53.48345,-2.24626(along Deansgate, Manchester, at 12 m/s), or a GPX file in Xcode. - Android emulator: Extended controls > Location: plan a route or load
a GPX or KML file and play it; or send fixes one at a time with
adb emu geo fix <longitude> <latitude>. - A service on your computer is
http://127.0.0.1:<port>from the iOS Simulator andhttp://10.0.2.2:<port>from the Android emulator, in a development build.
The example app (example-app/) does all of this; its README has the steps.
Free drive (no destination)
import { AtlasFreeDrive } from "@meridianatlas/react-native";
const freeDrive = new AtlasFreeDrive(bridges.freeDrive);
await freeDrive.initialize();
freeDrive.subscribe((update) => {
const { roadName, roadRef, speedLimit } = update.snapshot;
showRoad(roadName ?? roadRef, speedLimit ? `${speedLimit.value} ${speedLimit.unit}` : null);
for (const effect of update.effects)
if (effect.type === "roads_needed")
void loadRoads(effect.centre, effect.radiusM).then((roads) => freeDrive.setRoads(effect.centre, effect.radiusM, roads));
});
await freeDrive.begin();Loading roads
AtlasRoads answers roads_needed from the Atlas service (the key needs the
road_attributes feature; each answer is one unit):
import { AtlasRoads } from "@meridianatlas/react-native";
const roads = new AtlasRoads(atlas);
const nearby = await roads.nearby(effect.centre, effect.radiusM);
await freeDrive.setRoads(nearby.centre, nearby.radiusM, nearby.roads);Each road has name, ref (A56), highway, maxspeed ("30 mph"; null
when unknown, never a guess), maxspeedForward / maxspeedBackward and
oneway, as OpenStreetMap tags them. radiusM is 50 to 2000 metres.
Places
Search as the user types, then fetch the place they pick. Use one
sessionToken (16 or more characters) from the first keystroke to the pick.
fields says which fields to return; the common ones come back typed, and
raw has the rest.
import { AtlasPlaces } from "@meridianatlas/react-native";
const places = new AtlasPlaces(atlas);
const { suggestions } = await places.autocomplete({ input: typed, sessionToken });
const picked = suggestions.find((suggestion) => suggestion.placeId); // a query suggestion has no placeId
const place = await places.place(picked!.placeId!, { fields: ["id", "displayName", "formattedAddress", "location"], sessionToken });
// place.displayName, place.formattedAddress, place.location ([lon, lat]), place.types, place.rawsearchText({ textQuery }) and searchNearby({ locationRestriction }) return
places and nextPageToken; photo(placeId, photoId) returns the image bytes.
Traffic
The delay on a route you already have, and how fast each stretch is moving:
import { AtlasTraffic } from "@meridianatlas/react-native";
const traffic = new AtlasTraffic(atlas);
const advisory = await traffic.routeAdvisory(request); // request.requestId: a new UUID per advisory
// advisory.delaySeconds, advisory.speedReadingIntervals[i].state ("normal", "slow", "traffic_jam", "unknown")Route matrix
Distances and driving times from up to 25 origins to up to 25 destinations:
import { AtlasRouteMatrix } from "@meridianatlas/react-native";
const matrix = new AtlasRouteMatrix(atlas);
const result = await matrix.calculate({ requestId: "job-17", origins: drivers, destinations: [job] });
const seconds = result.cell("van-1", "job")?.durationSeconds; // null when no route was foundMulti-stop routes
One route through 2 to 64 stops in the order given, with a leg per pair:
import { AtlasMultiStop, atlasMultiStopRerouted } from "@meridianatlas/react-native";
const multiStop = new AtlasMultiStop(atlas);
let run = await multiStop.route({ requestId: "run-17", stops }); // stops: [{ id, coordinate, serviceSeconds? }]
// run.legs[i].distanceMetres, .durationSeconds, .guidance; run.plan drives the whole trip, stop by stop
// The map shows the whole trip: <AtlasMapView route={atlasMapRoute(run)} … />
await navigation.begin(run.plan);
// On route_replaced the session has rerouted to the next stop (effect.stopId); show the whole trip:
// if (effect.route) run = atlasMultiStopRerouted(run, effect, effect.route);- Arrivals. At each stop before the last an update carries a
stop_arrivedeffect (itsstopIdandlegIndex) and guidance carries on to the next stop; at the last,arrived(with itsstopId).leg_startedsays the car has left a stop (more than 50 m away, or off the route). The snapshot'slegIndex,legCount,nextStopIdandlegRemainingMsay which leg is being driven. - Reroutes go to the next stop not yet reached, never back to one reached
and never straight to the end; a car that drives past a stop without
reaching it is rerouted back to it. The session keeps the rest of the trip
after that stop;
atlasMultiStopReroutedgives the whole trip, for the map. Answering reroutes yourself, the route to that stop is enough. - Billing. The route is n − 1 Routes. With a configuration, guiding it is
one Navigation leg per stop: the first at
begin, each later one when the car leaves the stop before it, each ended at its stop. A run stopped at a stop is never charged the next leg, and the reroutes are free.
CarPlay and Android Auto
AtlasCarScreen puts the map, route choices and guidance on CarPlay and Android Auto.
The car screen is native and takes navigation updates from the module's own session:
configure it once, preview and show routes, and listen for the driver's choice.
Your app adds the plugin's CarPlay scene delegates to Info.plist and its car app
service (dev.meridianatlas.android.car.MeridianAtlasCarAppService) to the Android
manifest. AtlasRouteSimulator drives the session along a route without moving, for
testing and app review. The setup is in the CarPlay and Android Auto guide (docs/sdk/car-screens.md).
Errors
Every client throws AtlasError, with the same code on every Atlas SDK:
| Code | Meaning |
|---|---|
invalid_request | The request was refused as malformed (also thrown before sending) |
missing_api_key | The configuration's key is empty (thrown before sending) |
invalid_api_key | The key is wrong, revoked or expired: copy it again from Atlas Studio, or make a new one |
capability_required | The key doesn't have this feature; error.capability names it (turn it on for the key) |
app_not_allowed | The key is limited to other apps: make the client from the configuration with appIdentity (it sends your app), and list your bundle ID, package and every Android signing certificate, debug and release, on the key |
billing_inactive, usage_policy_required, usage_allowance_exhausted | The account can't be charged for this call |
rate_limit | Too many requests; error.retryAfterSeconds says when to try again |
outside_coverage | The origin or destination is outside the area Atlas routes (the UK at launch) |
route_unresolved | No route between those points |
leg_invalid, leg_destination_mismatch, leg_not_found | The navigation leg can't be used (ended, expired, unknown, had its 50 reroutes, or a new destination): start a new one. To subscribe's onError (an AtlasNavigationError with code leg_invalid), once: the session's reroutes go on without the leg, charged as routes |
leg_registration_failed | An AtlasNavigationError to subscribe's onError: the session couldn't register its leg (cause says why); guidance carries on, and its reroutes are charged as routes |
wrong_service_address | Something answered at the service address, but not the Atlas service: check baseUrl |
request_timeout, network_error | No answer in time, or no connection (or nothing at the service address) |
invalid_response | The answer couldn't be read (a wrong service address, or a network that needs a sign-in page) |
service_error | Anything else; error.status has the HTTP status |
error.retryable says whether trying the same call again later can work (no
connection, a timeout, a rate limit, a service error with a status of 500 or
more), and error.retryAfterSeconds when the service said. The message says
what to fix and ends with a link to the code's entry in Errors,
which has every code. error.requestId is the service's id for the request, to
quote to support.
import { AtlasError } from "@meridianatlas/react-native";
try {
await routes.route({ origin, destination });
} catch (error) {
if (!(error instanceof AtlasError)) throw error;
if (error.code === "capability_required") showStatus(`Turn on ${error.capability} for this key`);
else if (error.retryable) showStatus("No connection: try again"); // error.retryAfterSeconds, when the service said
else showStatus(error.message); // says what to fix, with a link
}Navigation and free drive throw AtlasNavigationError and
AtlasFreeDriveError (codes invalid_request, location_permission_required,
location_accuracy_reduced,
native_error, …), never a bare native-module error. subscribe() can be
called as often as you like (guidance and the map can each subscribe; they
share one native subscription), and an update that can't be read goes to
onError while updates carry on. The map's onMapError carries a code
too: viewer_unavailable when the viewer page didn't load (check viewerUrl
and the connection); scene_unavailable when no scenery came for that place
after every try;
viewer_error; context_lost; route_too_large, invalid_route or
unsupported_contract when the viewer refused what it was shown; or
invalid_route / invalid_position / invalid_snapshot / invalid_prop for
a prop it couldn't read.
Each client sends your key as X-Atlas-Key and the SDK version as
Atlas-Client: react-native/0.1.0-rc.6. Calls that are billed per request send
an Idempotency-Key; pass { idempotencyKey } (a UUID) to make a retry count once.