OfflineManager

An instance of this interface is a singleton that manages offline packs and ambient caching.

An offline pack represents a collection of resources needed to display a region offline, including map tiles, styles, and other assets. It allows you to selectively download regions of the map to be made available offline.

The ambient cache is a temporary storage mechanism used to improve map loading performance and reduce network requests. It caches map tiles and other resources that the map renders, allowing them to be retrieved faster on subsequent map views or when zooming into previously viewed areas. The ambient cache is distinct from offline packs, which are used for persistent offline access.

Properties

Link copied to clipboard
abstract val packs: Set<OfflinePack>

A list of all known offline packs. Backed by androidx.compose.runtime.State.

Functions

Link copied to clipboard
abstract suspend fun clearAmbientCache()

Clears the ambient cache by deleting resources. This method does not affect resources shared with offline regions.

Link copied to clipboard
abstract suspend fun create(definition: OfflinePackDefinition, metadata: ByteArray = ByteArray(0)): OfflinePack

Creates and registers an offline pack that downloads the resources needed to use the given region offline. The pack starts paused; to actually start the download, call resume.

Link copied to clipboard
abstract suspend fun delete(pack: OfflinePack)

Unregisters the given offline pack and allows resources that are no longer required by any remaining packs to be freed.

Link copied to clipboard
abstract suspend fun invalidate(pack: OfflinePack)

Invalidates the specified offline pack. This method checks that the tiles in the specified pack match those from the server. Local tiles that do not match the latest version on the server are updated.

Link copied to clipboard
abstract suspend fun invalidateAmbientCache()

Invalidates the ambient cache. This method checks that the tiles in the ambient cache match those from the server. If the local tiles do not match those on the server, they are re-downloaded.

Link copied to clipboard
abstract fun pause(pack: OfflinePack)

Pause downloading if the pack is downloading.

Link copied to clipboard
abstract fun resume(pack: OfflinePack)

Resume downloading if the pack is paused. Must be called after create to start downloading.

Link copied to clipboard
abstract suspend fun setMaximumAmbientCacheSize(size: Long)

Sets the maximum ambient cache size in bytes. The default maximum cache size is 50 MB. To disable ambient caching, set the maximum ambient cache size to 0. Setting the maximum ambient cache size does not impact the maximum size of offline packs.

Link copied to clipboard
abstract fun setTileCountLimit(limit: Long)

Sets the maximum number of tiles that may be downloaded and stored on the current device. By default, the limit is set to 6000.