Beta
Navigation SDK for iOS v2

Offline

There are two main kinds of offline functionality: predictive caching and offline manager (which is coming soon). Predictive caching is fully automatic and based on the driver’s behavior. It allows offline navigation around the user’s current location, the destination, and the route itself.

Predictive caching

To add predictive caching to your application, pass PredictiveCacheOptions instance into the NavigationOptions initializer as you configure a NavigationViewController or manually call NavigationMapView.enablePredictiveCaching(options:).

To add predictive caching using NavigationViewController:

let options = NavigationOptions(styles: styles, navigationService: navigationService(route: route, routeIndex: 0, options: routeOptions), predictiveCacheOptions: PredictiveCacheOptions())
let navigationViewController = NavigationViewController(for: route, routeIndex: 0, routeOptions: routeOptions, navigationOptions: options)

To add predictive caching using NavigationMapView.enablePredictiveCaching(options:):

if let predictiveCacheOptions = navigationOptions?.predictiveCacheOptions {
    navigationMapView?.enablePredictiveCaching(options: predictiveCacheOptions)
}
Map style support for predictive caching

Predictive caching only supports map styles that do not use source compositing. You may need to check your style in Mapbox Studio to make sure source compositing is turned off. Default Mapbox styles (like Mapbox Streets and Mapbox Outdoors) have compositing turned on and will not work with predictive caching by default. To use a Default Mapbox style with predictive caching:

  1. Create a new style based on the template style you prefer.
  2. Turn off compositing in your style's settings.
  3. Publish your style.
  4. Reference your style in your application.

Predictive caching only supports sources hosted with Mapbox. These sources will have a URL starts with mapbox://.

Configure predictive caching

When predictive caching is enabled, the Navigation SDK will create a cache of data within three configurable boundaries, each with its own default value:

  1. Radius around the user's location. Defaults to 2,000 meters. Use PredictiveCacheOptions.currentLocationRadius to configure this value.
  2. Buffer around the route. Defaults to 500 meters. Use PredictiveCacheOptions.routeBufferRadius to configure this value.
  3. Radius around the destination. Defaults to 5,000 meters. Use PredictiveCacheOptions.destinationLocationRadius to configure this value.

To configure predictive caching, pass values, in meters, to PrediictiveCacheOptions:

var predictiveCacheOptions = PredictiveCacheOptions()
predictiveCacheOptions.routeBufferRadius = 300
predictiveCacheOptions.currentLocationRadius = 2000
predictiveCacheOptions.destinationLocationRadius = 3000
let options = NavigationOptions(styles: styles, navigationService: navigationService(route: route, routeIndex: 0, options: routeOptions), predictiveCacheOptions: predictiveCacheOptions)
let navigationViewController = NavigationViewController(for: route, routeIndex: 0, routeOptions: routeOptions, navigationOptions: options)

Estimate predictive caching data use

Data usage depends on the configured radius and the dataset being used. For default Mapbox data, example usage is:

  • Berlin, 15km radius: 136 MB maps, 42 MB navigation
  • Chicago, 15km radius: 74 MB maps, 43 MB navigation
  • London, 15km radius: 145 MB maps, 90 MB navigation
  • Atlanta, 100 miles radius: 659 MB maps, 156 MB navigation

Offline manager

Offline manager coming soon

The offline manager feature in the Navigation SDK for iOS is currently in development. When released, offline manager will allow users to create offline regions ahead of time, enabling routing functionality in non-connected environments. In areas of no cellular connectivity, or on a device with no SIM card, your users can use turn-by-turn navigation and request new routes. If they go off-route, the system can reroute and keep them headed to their destination without requiring network connectivity. The offline manager moves the routing engine and the routing data from the server onto your user’s device, so there’s no need to make HTTP API calls for routing information.