Meridian Atlas for React Native

Turn-by-turn navigation for React Native apps: routes with lane-level guidance, spoken announcements timed for you (and an opt-in voice to say them), rerouting, free drive with road names and speed limits, the Atlas 3D map, and offline routing. Guidance runs in the package's native module on iOS and Android, which also runs GPS while a session is active, so it keeps going with the screen locked and through tunnels.

Requirements

  • React Native 0.74 or later (tested on 0.88 with the New Architecture)
  • iOS 15.1 or later (React Native's own minimum), Android 8.0 (API 26) or later
  • A Meridian Atlas API key (an app key made in Atlas Studio for your bundle ID, package name and signing certificates) and service URL

Install

Until the package is on a registry, install it from the release archive:

Shell
npm install ./meridianatlas-react-native-0.1.0-rc.6.tgz
cd ios && pod install

The native module autolinks. Rebuild the app after installing. New React Native apps start at API 24, so set minSdkVersion = 26 in android/build.gradle.

Permissions

  • iOS: add NSLocationWhenInUseUsageDescription to Info.plist. For guidance with the screen locked, also add the location background mode.
  • Android: the package declares location, foreground-service and notification permissions. Ask for ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION together at runtime before starting (Android 12 and later ignore a request for fine alone), and on Android 13+ for POST_NOTIFICATIONS, so the "Navigating" notification of the service that keeps guidance running shows.

begin() without location permission fails with AtlasNavigationError (or AtlasFreeDriveError) code location_permission_required, and with only approximate location location_accuracy_reduced, on iOS and Android: ask first, then begin. Every error's message says what to fix; Errors has every code.

A first route

TypeScript
import { NativeEventEmitter, NativeModules } from "react-native";
import {
  AtlasNavigation, AtlasRoutes, atlasAppIdentity, atlasConfiguration, createAtlasNativeBridges,
} from "@meridianatlas/react-native";

const bridges = createAtlasNativeBridges(NativeModules.MeridianAtlas, NativeEventEmitter);
// The configuration names your app on every request, so an app key works.
// The service and map viewer default to api. and maps.meridianatlas.dev (not live yet:
// beta partners pass baseUrl and viewerUrl, the addresses Meridian gave them).
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
await navigation.initialize();

navigation.subscribe((update) => {
  for (const effect of update.effects) {
    // The session rerouted (from the car, facing its way, asked the way the route was): show the new route.
    if (effect.type === "route_replaced" && effect.route) showRoute(effect.route);
  }
});

const route = await routes.route({ origin: [-2.2511, 53.4747], destination: [-2.246, 53.4837] });
await navigation.begin(route.plan);
// route.guidance: the instructions to show. Each update's announcements say what to speak,
// and when: new AtlasVoice(bridges.voice) says them, or new AtlasVoice({ speak }) with your own

What's in it

  • AtlasRoutes: routes from the Atlas service, with structured guidance.
  • AtlasNavigation: route guidance. It reroutes by itself (or with your own routing, rerouting); updates carry the progress, each new route and the effects your app acts on: pause and resume, arrival.
  • AtlasFreeDrive: the current road and its speed limit, with no destination.
  • The Atlas 3D map as a native view, following the car: requireNativeComponent<AtlasMapViewProps>(ATLAS_MAP_VIEW).
  • AtlasOfflineRoutes: routes on an offline package installed on the device (downloads come after launch).
  • AtlasPlaces: autocomplete, text and nearby search, place details and photos.
  • AtlasTraffic: the traffic delay on a route.
  • AtlasRouteMatrix: distances and driving times between many origins and destinations.
  • AtlasMultiStop: one route through several stops, in order.
  • AtlasCarScreen: CarPlay and Android Auto. The car screen is native and gets navigation updates natively; the CarPlay and Android Auto guide (docs/sdk/car-screens.md) has the Info.plist and manifest entries.
  • AtlasRouteSimulator: drives a navigation session along a route, for testing and app review.

The service clients throw AtlasError, with the same code on every Atlas SDK (missing_api_key, invalid_api_key, capability_required, rate_limit, network_error, outside_coverage, …), a message that says what to fix, and retryable; navigation throws AtlasNavigationError and free drive AtlasFreeDriveError, with the same codes as Flutter's (invalid_request, location_permission_required, location_accuracy_reduced, native_error, …), never a bare native error. Subscribe as often as you like (guidance and the map, say): subscribers share one native subscription, and an update that can't be read goes to onError while updates carry on. Each feature is turned on per API key.

Licence

Copyright Meridian. All rights reserved. Use is subject to your Meridian Atlas agreement.

Proposal · draft