offlineManagerLegacy
import { offlineManagerLegacy } from '@rnmapbox/maps';
offlineManagerLegacy
OfflineManagerLegacy implements a singleton (shared object) that manages offline packs. All of this class’s instance methods are asynchronous, reflecting the fact that offline resources are stored in a database. The shared object maintains a canonical collection of offline packs.
methods
createPack(options)
Creates and registers an offline pack that downloads the resources needed to use the given region offline.
arguments
Name | Type | Required | Description |
---|---|---|---|
options | OfflineCreatePackOptions | Yes | Create options for a offline pack that specifices zoom levels, style url, and the region to download. |
await Mapbox.offlineManager.createPack({
name: 'offlinePack',
styleURL: 'mapbox://...',
minZoom: 14,
maxZoom: 20,
bounds: [[neLng, neLat], [swLng, swLat]]
})
invalidatePack(name)
Invalidates the specified offline pack. This method checks that the tiles in the specified offline pack match those from the server. Local tiles that do not match the latest version on the server are updated.This is more efficient than deleting the offline pack and downloading it again. If the data stored locally matches that on the server, new data will not be downloaded.
arguments
Name | Type | Required | Description |
---|---|---|---|
name | String | Yes | Name of the offline pack. |
await Mapbox.offlineManagerLegacy.invalidatePack('packName')
deletePack(name)
Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be potentially freed.
arguments
Name | Type | Required | Description |
---|---|---|---|
name | String | Yes | Name of the offline pack. |
await Mapbox.offlineManagerLegacy.deletePack('packName')
migrateOfflineCache()
Migrates the offline cache from pre-v10 SDKs to the new v10 cache location
arguments
Name | Type | Required | Description |
---|
await Mapbox.offlineManager.migrateOfflineCache()
resetDatabase()
Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.
arguments
Name | Type | Required | Description |
---|
await Mapbox.offlineManager.resetDatabase();
getPacks()
Retrieves all the current offline packs that are stored in the database.
arguments
Name | Type | Required | Description |
---|
const offlinePacks = await Mapbox.offlineManagerLegacy.getPacks();
getPack(name)
Retrieves an offline pack that is stored in the database by name.
arguments
Name | Type | Required | Description |
---|---|---|---|
name | String | Yes | Name of the offline pack. |
const offlinePack = await Mapbox.offlineManagerLegacy.getPack();