PredictiveCacheController
Predictive caching is a system that downloads necessary visual map and guidance data resources along the route upfront, before they are needed, in an attempt to provide a smooth experience even when connectivity is lost while using the app.
Once instantiated, the controller will immediately start caching guidance and search data.
In order to start caching map data, provide an instance via createStyleMapControllers. To specify styles to cache, pass a list of Mapbox style URIs via createStyleMapControllers. Source id's should look like "mapbox://mapbox.satellite", "mapbox://mapbox.mapbox-terrain-v2". The system only supports source hosted on Mapbox Services which URL starts with "mapbox://". If no ids are passed all available style sources will be cached.
The controller as well as MapboxNavigation instance it's holding can have a different lifecycle than the MapboxMap instance, so make sure to call removeMapControllers whenever the MapView is destroyed to avoid leaking references or downloading unnecessary resources. When the map instance is recreated, set it back with createStyleMapControllers.
The map instance has to be configured with the same TileStore instance that was provided to RoutingTilesOptions.tileStore. You need to call TileStore.create with a path and pass it to MapboxMapsOptions.tileStore or use the Maps SDK's tile store path XML attribute.
Call onDestroy to cleanup all map, navigation and search state related references. This can be called when navigation session finishes and predictive caching is not needed anymore.
When migrating please ensure you have cleaned up old navigation tiles cache folder to reclaim disk space. Navigation SDK 2.0 caches navigation tiles in a default folder under
APP_FOLDER/mbx_nav/tiles/api.mapbox.com
. Previous versions of Nav SDK used to cache tiles under a default folderAPP_FOLDER/Offline/api.mapbox.com/$tilesVersion/tiles
. Old cache is not compatible with a new version of SDK 2.0. It makes sense to delete any folders used previously for caching including a default one.OnboardRouterOptions
enabled you to specify a path where nav-tiles will be saved and if a custom directory was used, it should be cleared as well.
Parameters
PredictiveCacheOptions options to instantiate instance of PredictiveCacheController
Constructors
Functions
Create Maps cache controllers for a map instance. Call when a new map instance is available.
Remove the map instance for Maps data. Call this whenever the MapView is destroyed to avoid leaking references or downloading unnecessary resources.