Skip to main content

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

NameTypeRequiredDescription
optionsOfflineCreatePackOptionsYesCreate 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

NameTypeRequiredDescription
nameStringYesName 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

NameTypeRequiredDescription
nameStringYesName 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

NameTypeRequiredDescription
await Mapbox.offlineManager.migrateOfflineCache()

resetDatabase()

Deletes the existing database, which includes both the ambient cache and offline packs, then reinitializes it.

arguments

NameTypeRequiredDescription
await Mapbox.offlineManager.resetDatabase();

getPacks()

Retrieves all the current offline packs that are stored in the database.

arguments

NameTypeRequiredDescription
const offlinePacks = await Mapbox.offlineManagerLegacy.getPacks();

getPack(name)

Retrieves an offline pack that is stored in the database by name.

arguments

NameTypeRequiredDescription
nameStringYesName of the offline pack.
const offlinePack = await Mapbox.offlineManagerLegacy.getPack();