Flutter 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 (for example --dart-define-from-file with a file you don't commit). Studio's code sample needs only the key: the configuration defaults to the Atlas service and map viewer (below).

Install

Unpack the release archive (meridian_atlas-0.1.0-rc.6.tar.gz) next to your app and depend on it by path:

YAML
dependencies:
  meridian_atlas:
    path: ../meridian_atlas

It needs iOS 15 and Android 8.0 (API 26) or later. New Flutter apps start lower, so set minSdk = 26 in android/app/build.gradle.kts and platform :ios, '15.0' in ios/Podfile.

It is a Flutter plugin: the Atlas native core comes with it on iOS and Android, and runs GPS itself while a session is active. Your app asks for location permission:

  • iOS: add NSLocationWhenInUseUsageDescription to Info.plist and ask with Core Location's requestWhenInUseAuthorization() (the plugin never asks); for guidance with the screen locked, also the location background mode.
  • Android: the plugin declares ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION; request both together at runtime (Android 12 and later ignore a request for fine alone) before starting a session. Guidance carries on with the screen off through a location foreground service with a "Navigating" notification; on Android 13+ request POST_NOTIFICATIONS so the notification shows.

The example app does both with the platforms' own prompts (its MainActivity and AppDelegate answer a meridian_atlas_example/location method channel), and says what to do when location is off or only approximate.

begin() without location permission throws AtlasNavigationException with code location_permission_required (AtlasNavigationErrorCode.locationPermissionRequired), 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:

Dart
final atlas = await AtlasConfiguration.forThisApp(apiKey: apiKey);
final routes = AtlasRoutes.fromConfiguration(atlas);
final navigation = AtlasNavigation(MethodChannelAtlasNavigationBridge(), configuration: atlas); // reroutes and registers its legs itself
// AtlasMultiStop, AtlasRouteMatrix, AtlasPlaces, AtlasTraffic, AtlasNavigationLegs and AtlasRoads too;
// the map: AtlasMapView(configuration: atlas, onCreated: ...) (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:

Dart
final atlas = await AtlasConfiguration.forThisApp(
    apiKey: apiKey, baseUrl: 'https://your-atlas-host', viewerUrl: 'https://your-atlas-viewer');

(atlasDefaultBaseUrl and atlasDefaultViewerUrl name the defaults.) URLs must use HTTPS; plain HTTP works only in a debug build, to this device (localhost, 127.0.0.1) or the Android emulator's host (10.0.2.2). timeout (default 30 seconds) applies to each request. forThisApp asks the plugin, once, for your app's identity: 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. The AtlasConfiguration(...) constructor sends no app unless you pass appIdentity (server keys don't need it). The older constructors, 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 debug build also needs a network security config that allows cleartext to a plain-HTTP host.

Getting a route

Dart
final routes = AtlasRoutes.fromConfiguration(atlas); // atlas: from "Configure the key"
final route = await routes.route(
  origin: const AtlasCoordinate(-2.2511, 53.4747),
  destination: const AtlasCoordinate(-2.246, 53.4837),
);
// route.guidance: the steps to show and speak; route.plan: what navigation.begin() takes
// route.speedSections: the speed limits along it

Pass departureTime: (a DateTime) to plan a later journey, trafficAware: true to allow for traffic, and approach: AtlasApproach.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. Every client uses dart:io by default (redirects refused, so the key never follows one); pass transport: to use your own HTTP client. A failure is an AtlasException (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:

Dart
final offline = AtlasOfflineRoutes();
await offline.initialize(); // fails closed if the plugin's contract differs
await offline.open(
  routingPath: '$packageFolder/routing.bin',
  waysPath: '$packageFolder/ways.bin', // road names for the instructions
  releaseId: manifest.releaseId,
);
final route = await offline.route(
  origin: const AtlasCoordinate(-2.2511, 53.4747),
  destination: const AtlasCoordinate(-2.246, 53.4837),
);
await navigation.begin(route.plan); // the same AtlasRoute as online

packageFolder is wherever your package persistence installed it. Routing runs off the main thread in the plugin, and reroute(effect) works as online. Errors are AtlasException 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 Dart download and install API is in package:meridian_atlas/experimental_offline.dart: it isn't finished and may change in any release, and its failures are AtlasOfflineDownloadException with a code.

Route guidance

Dart
final navigation = AtlasNavigation(MethodChannelAtlasNavigationBridge(), configuration: atlas);
await navigation.initialize(); // fails closed if the native contract differs
navigation.updates().listen((update) {
  for (final effect in update.effects) {
    switch (effect.type) {
      // The session rerouted: show the new route, and guide by its steps from now on.
      case AtlasNavigationEffectType.routeReplaced:
        if (effect.route case final route?) showRoute(route);
      case AtlasNavigationEffectType.pauseGuidance:
        showStatus('Waiting for GPS');
      case AtlasNavigationEffectType.arrived:
        showStatus('You have arrived');
      default:
        break;
    }
  }
});
await navigation.begin(route.plan); // the AtlasRoute from routes.route(...)

Each step in route.guidance has an instruction ready to show and speak. 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: routeReplaced 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:

  • requestReroute: a route is being fetched (phase is rerouting).
  • routeReplaced: the new route is in use (effect.route).
  • rerouteFailed: the fetch failed (effect.reason is the error's code, or no_answer after 20 seconds). The old route is kept, and the session asks again at effect.retryAtMs: after 3 seconds, then 6, 12 and so on, up to a minute.
  • rerouteCancelled: the car came back to the route (reason is back_on_route), so the fetch was dropped.
  • rerouteDeferred: no connection (offline), or waiting before asking again (backoff).

Answering reroutes yourself

Pass rerouting: to use your own routing:

Dart
// Your routing, run as automatic rerouting is: one fetch at a time, dropped when no longer needed.
final custom = AtlasNavigation(MethodChannelAtlasNavigationBridge(), configuration: atlas,
    rerouting: AtlasRerouting.custom((effect) => yourRouter.route(effect.origin!, effect.destination!, effect.headingDegrees)));
// Or answer each requestReroute yourself.
final manual = AtlasNavigation(MethodChannelAtlasNavigationBridge(), configuration: atlas, rerouting: AtlasRerouting.manual);
await manual.initialize();
manual.updates().listen((update) {
  for (final effect in update.effects.where((e) => e.type == AtlasNavigationEffectType.requestReroute)) {
    final requestId = effect.requestId!;
    unawaited(yourRouter.route(effect.origin!, effect.destination!, effect.headingDegrees).then(
        (plan) => manual.completeReroute(requestId, plan),
        onError: (Object error) => manual.failReroute(requestId, error)));
  }
});

With AtlasRerouting.manual, and without a configuration (AtlasNavigation(MethodChannelAtlasNavigationBridge())), answer every requestReroute: 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.

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:

Dart
final navigation = AtlasNavigation(MethodChannelAtlasNavigationBridge(), configuration: atlas);
await navigation.initialize();
navigation.updates().listen((update) { /* as in "Route guidance" */ }, onError: (Object error) {
  // leg_registration_failed: guidance carries on; leg_invalid (50 reroutes, or the leg refused): reroutes go on without it
  if (error is AtlasNavigationException) log(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)
  • begin registers 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.legId is the leg, once registered.
  • Each requestReroute effect carries legId, and the session's reroutes send it (so does routes.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, and updates() gets an AtlasNavigationException error event with code leg_invalid once. 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 same Idempotency-Key, so the leg is charged once. If it still can't be registered (or the key is refused), updates() gets an AtlasNavigationException error event with code leg_registration_failed, once; its cause is the service's AtlasException (capability, status). Guidance carries on, and its reroutes are charged as routes.
  • Arrival ends the leg (arrived), and so does stop() (cancelled).
  • transport: is for tests or your own networking.

Without a configuration the session contacts no server; do the same by hand:

Dart
final legs = AtlasNavigationLegs.fromConfiguration(atlas);
final leg = await legs.start(route.coordinates.last);                         // when guidance starts
final replacement = await routes.reroute(effect, legId: leg.legId);           // on requestReroute: included in the leg
await legs.end(leg.legId, reason: AtlasNavigationLegEndReason.arrived);       // on arrival (cancelled when the driver stops)

Pass the original route's options to keep them (routes.rerouteWith(effect, route.plan.options, legId: leg.legId)). 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 requestReroute after a timeout or lost connection reuses its Idempotency-Key, so a request that did reach the service counts once.

Showing the map

AtlasMapView is the Atlas 3D map, from the Atlas viewer at the configuration's viewerUrl (a native view on both platforms; no web-view package needed). The viewer gets the configuration's key for its scenery, in the page, never in its URL. Show it the route, then give it each snapshot to move the car, estimated progress through a tunnel included:

Dart
AtlasMapView(
  configuration: atlas,
  presentation: AtlasMapPresentation(style: AtlasMapStyle.standard, navigationUI: true),
  onCreated: (map) {
    map.showAtlasRoute(route); // the AtlasRoute whose plan you began
    map.errors.listen((error) => showStatus('Map: ${error.message}'));
    map.warnings.listen((warning) => showMapNotice(warning.active));
    navigation.updates().listen((update) => map.update(update.snapshot));
  },
)

A viewerBaseUrl: you pass is loaded instead of the configuration's viewerUrl; with neither a configuration nor viewerBaseUrl:, building the view throws an ArgumentError. AtlasMapView(viewerBaseUrl: viewer, ...) still works and sends no key.

errors says the map couldn't start or has stopped (AtlasMapError, with a code: 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 when it lost its graphics context and three reloads didn't bring it back, or route_too_large, invalid_route or unsupported_contract when the viewer refused what it was shown). warnings are problems the map carries on through (AtlasMapWarning: map_detail_unavailable, context_lost, runtime_error, quality_reduced), with active true when one starts and false when it clears. A lost graphics context is recovered by reloading the map, which keeps what it was shown; ready completes the first time the map is ready and readyEvents has every time, reloads included.

showAtlasRoute (or showMultiStopRoute for an AtlasMultiStopRoute) gives the map the route's guidance, so the route line moves into the lane each junction needs, and its speed limits. showRoute(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:

Dart
await map.showAtlasRoute(route, destination: const AtlasMapPlace('Interact CC Wigan', address: 'Wallgate, Wigan WN1 1BA'));
// A multi-stop trip: map.showMultiStopRoute(trip, stops: {'tesco': const AtlasMapPlace('Tesco Pemberton')})
map.voice = voice; // the AtlasVoice speaking your announcements: the mute button mutes and unmutes it
map.arrivalActions.listen((action) {
  if (action.kind == AtlasArrivalActionKind.end) navigation.stop();
});

With map.voice set, the mute button and the voice follow each other: there is nothing more to write, and voice.setMuted(true) from your own settings shows on the button. If you speak with something other than AtlasVoice, pass the taps on yourself: map.voiceMutedChanges.listen((muted) => myVoice.mute(muted)). map.setVoiceMuted(...) shows your app's own setting on the button, and map.isVoiceMuted is the state. map.recentre() and followingChanges do what the button does, for your own controls; map.showOverview(), isOverview and overviewChanges do the same for the overview. AtlasMapPresentation(navigationPanels: {...}) turns panels off one by one (a set of AtlasNavigationPanel). Without AtlasNavigationPanel.recentre, the map doesn't move under the driver's fingers, and the overview button doesn't show. AtlasMapPresentation(autoRecentreAfter: const Duration(seconds: 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 SafeArea): 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 widgets 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: map.setInsets(EdgeInsets.only(bottom: sheetHeight)).

quality: sets how much the map spends on each frame: AtlasMapQuality.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. The controller's quality says which tier the map started at, once it is ready.

After a reroute, show the new route (routeReplaced's route) the same way: it is swapped in place, without reloading the map. When the AtlasMapView goes, its controller is disposed: its streams close and later calls do nothing, so cancel the subscriptions that feed it (or keep the map for the drive). In free drive, showPosition at the car's first matched point and pass each free-drive snapshot to map.updateFreeDrive; the car follows the road it is matched to, and the map shows the speed limit there. The viewer is reached over the network: on Android, plain HTTP (a development viewer) needs a network security config allowing it.

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.plan carries it, so a route from AtlasRoutes or AtlasMultiStop is announced. A hand-made AtlasRoutePlan without guidance is guided in silence.
  • When: warnings come further ahead on faster roads, and close manoeuvres are joined ("…, then turn left"). Nothing is said while phase isn't onRoute, 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 plugin says them the British way.

To have Atlas speak them, use the opt-in AtlasVoice:

Dart
final voice = AtlasVoice();   // the device's best British voice
voice.events.listen((event) {
  // willSpeak: duck your own audio; didSpeak with speaking false: restore it
});
navigation.updates().listen(voice.handle);
  • Voices:
    • await voice.voices(locale: 'en-GB', minimumQuality: 'enhanced') lists the installed voices, best first.
    • Choose one with voice.selectVoice(id); voice.preview(voiceId: 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 audio background 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() and stop().
  • Your own voice: AtlasVoice.custom(speak: (text, ssml) => tts.speak(text)), for example with flutter_tts or a cloud neural voice. The future completes when the prompt has been said. Or skip AtlasVoice and speak each announcement's text yourself.

Testing in the simulator and emulator

The plugin runs GPS itself, so give the simulator or emulator a drive:

  • iOS Simulator: xcrun simctl privacy booted grant location <your bundle ID>, then xcrun 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 and http://10.0.2.2:<port> from the Android emulator, in a debug build.

The example app (example/) does all of this; its README has the steps.

Free drive (no destination)

Dart
final freeDrive = AtlasFreeDrive(MethodChannelAtlasFreeDriveBridge());
await freeDrive.initialize();
freeDrive.updates().listen((update) {
  showRoad(update.snapshot.roadName ?? update.snapshot.roadRef, update.snapshot.speedLimit);
  for (final effect in update.effects) {
    if (effect.type == AtlasFreeDriveEffectType.roadsNeeded) {
      loadRoads(effect.centre!, effect.radiusM!).then((roads) => freeDrive.setRoads(effect.centre!, effect.radiusM!, roads));
    }
  }
});
await freeDrive.begin();

Loading roads

AtlasRoads answers roadsNeeded from the Atlas service (the key needs the road_attributes feature; each answer is one unit):

Dart
final roads = AtlasRoads.fromConfiguration(atlas);
final nearby = await roads.nearby(effect.centre!, effect.radiusM!);
await freeDrive.setRoads(nearby.centre, nearby.radiusM, nearby.roads);

Each AtlasRoad 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.

Dart
final places = AtlasPlaces.fromConfiguration(atlas);
final result = await places.autocomplete({'input': typed, 'sessionToken': sessionToken});
final picked = result.suggestions.firstWhere((s) => s.placeId != null); // a query suggestion has no placeId
final place = await places.place(picked.placeId!,
    fields: ['id', 'displayName', 'formattedAddress', 'location'], sessionToken: sessionToken);
// place.displayName, place.formattedAddress, place.location (an AtlasCoordinate), place.types, place.raw

searchText({'textQuery': …}, fields: …) and searchNearby 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:

Dart
final traffic = AtlasTraffic.fromConfiguration(atlas);
final 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:

Dart
final matrix = AtlasRouteMatrix.fromConfiguration(atlas);
final result = await matrix.calculate(AtlasRouteMatrixRequest(requestId: 'job-17', origins: drivers, destinations: [job]));
final seconds = result.cell('van-1', 'job')?.durationSeconds; // null when no route was found

Multi-stop routes

One route through 2 to 64 stops in the order given, with a leg per pair:

Dart
final multiStop = AtlasMultiStop.fromConfiguration(atlas);
var run = await multiStop.route(AtlasMultiStopRequest(requestId: 'run-17', stops: stops));
// run.legs[i].distanceMetres, .durationSeconds, .guidance; run.plan drives the whole trip, stop by stop
await map.showMultiStopRoute(run);
await navigation.begin(run.plan);
// On routeReplaced the session has rerouted to the next stop (effect.stopId); show the whole trip:
//   if (effect.route case final route?) { run = run.rerouted(effect, route); await map.showMultiStopRoute(run); }
  • Arrivals. At each stop before the last an update carries a stopArrived effect (its stopId and legIndex) and guidance carries on to the next stop; at the last, arrived (with its stopId). legStarted says the car has left a stop (more than 50 m away, or off the route). The snapshot's legIndex, legCount, nextStopId and legRemainingM say 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; run.rerouted(effect, route) gives 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 plugin's own session: configure it once, preview and show routes, and listen to events 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 AtlasException, with the same code on every Atlas SDK:

CodeMeaning
invalid_requestThe request was refused as malformed (also thrown before sending)
missing_api_keyThe configuration's key is empty (thrown before sending)
invalid_api_keyThe key is wrong, revoked or expired: copy it again from Atlas Studio, or make a new one
capability_requiredThe key doesn't have this feature; capability names it (turn it on for the key)
app_not_allowedThe key is limited to other apps: make the client from AtlasConfiguration.forThisApp (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_exhaustedThe account can't be charged for this call
rate_limitToo many requests; retryAfterSeconds says when to try again
outside_coverageThe origin or destination is outside the area Atlas routes (the UK at launch)
route_unresolvedNo route between those points
leg_invalid, leg_destination_mismatch, leg_not_foundThe navigation leg can't be used (ended, expired, unknown, had its 50 reroutes, or a new destination): start a new one. On updates() (an AtlasNavigationException, AtlasNavigationErrorCode.legInvalid), once: the session's reroutes go on without the leg, charged as routes
leg_registration_failed (AtlasNavigationErrorCode.legRegistrationFailed)An AtlasNavigationException error event on updates(): the session couldn't register its leg (cause says why); guidance carries on, and its reroutes are charged as routes
wrong_service_addressSomething answered at the service address, but not the Atlas service: check baseUrl
request_timeout, network_errorNo answer in time, or no connection (or nothing at the service address)
invalid_responseThe answer couldn't be read (a wrong service address, or a network that needs a sign-in page)
service_errorAnything else; status has the HTTP status

isRetryable 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 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. requestId is the service's id for the request, to quote to support.

Dart
try {
  await routes.route(origin: origin, destination: destination);
} on AtlasException catch (error) {
  if (error.code == 'capability_required') {
    showStatus('Turn on ${error.capability} for this key');
  } else if (error.isRetryable) {
    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 AtlasNavigationException and AtlasFreeDriveException, never a PlatformException. Their code is an enum (AtlasNavigationErrorCode, AtlasFreeDriveErrorCode) whose wire is the code every Atlas SDK uses: invalid_request, location_permission_required, location_accuracy_reduced, native_error, leg_registration_failed and so on (fromWire goes the other way, and the exceptions print it). updates() can be listened to as often as you like (guidance and the map above share one native subscription); an update that can't be read is an error event and the stream carries on, so listen with onError.

Each client sends your key as X-Atlas-Key and the SDK version as Atlas-Client: flutter/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.

Proposal · draft