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
Which style to cache for. Must be the style the live map renders