MPMapboxBaseMapCacheProvider

The base-map tile cache for Mapbox, which downloads the base map underneath MapsIndoors so that a map can render with no network connection.

Two things have to exist for a style to render offline, and this provider loads both: a style pack (the style JSON, sprites and fonts) and a tile region (the tile pixels for an area and zoom range). Having one without the other is the worst outcome available — storage fills and nothing renders — so a style-pack failure stops the region download rather than proceeding into it.

Construct it with no map in existence and register it once:

MPDataSetCacheManager.getInstance().setBaseMapCacheProvider(
MPMapboxBaseMapCacheProvider(MPMapboxStyleSource.MapsIndoorsDefault)
)

The style is an explicit choice with no default, because caching the wrong style is silent until the device goes offline — see MPMapboxStyleSource. No Mapbox access token is passed; Mapbox reads the ambient one the host app configures.

Unlike the rest of this adapter, which launches a throwaway CoroutineScope per call site and cancels nothing, this class holds one scope for its lifetime and terminate cancels it. Caching a region is a multi-minute network download, so something has to be able to stop it, and a scope left live after MapsIndoors.destroy() would be a genuine leak. Its job is a SupervisorJob so that one venue's failed download does not cancel its siblings.

Parameters

styleSource

Which style to cache for. Must be the style the live map renders

Constructors

Link copied to clipboard
constructor(styleSource: MPMapboxStyleSource)

Functions

Link copied to clipboard
Link copied to clipboard
open override fun cachedRegionSize(regionId: String, listener: OnResultAndDataReadyListener<Long>)
Link copied to clipboard
open override fun cacheRegion(regionId: String, bounds: MPLatLngBounds, minZoom: Int, maxZoom: Int, listener: MPBaseMapCacheRegionListener?)
Link copied to clipboard
open override fun isBaseMapCachingSupported(): Boolean
Link copied to clipboard
open override fun removeCachedRegion(regionId: String, listener: OnResultReadyListener?)
Link copied to clipboard
open override fun terminate()