With following offline Mapbox docs, I defined tileStore, resourceOptions, offlineManager and tilesetDescriptor same as codes below.
private val tileStore: TileStore by lazy {TileStore.create().also{it.setOption(TileStoreOptions
.MAPBOX_ACCESS_TOKEN, TileDataDomain.MAPS, Value(getString(R.string.mapbox_access_token))) } }
private val resourceOptions: ResourceOptions by lazy { ResourceOptions.Builder()
.applyDefaultParams(this).tileStore(tileStore).build() }
private val offlineManager: OfflineManager by lazy { OfflineManager(resourceOptions) }
val tilesetDescriptor = offlineManager.createTilesetDescriptor(TilesetDescriptorOptions.Builder()
.styleURI(Style.MAPBOX_STREETS).minZoom(0).maxZoom(16).build())
Then I download Style and tilePack
stylePackCancelable1=offlineManager.loadStylePack(Style.MAPBOX_STREETS,StylePackLoadOptions
.Builder().glyphsRasterizationMode(GlyphsRasterizationMode.IDEOGRAPHS_RASTERIZED_LOCALLY)
.metadata(Value(STYLE_PACK_METADATA1)).build())
tilePackCancelable1=tileStore.loadTileRegion(TILE_REGION_ID1,TileRegionLoadOptions.Builder()
.geometry(TOKYO).descriptors(listOf(tilesetDescriptor)).metadata(Value(TILE_REGION_METADATA1))
.acceptExpired(true).networkRestriction(NetworkRestriction.NONE).build())
Finally, I rendered map in one frameLayout
mapView = MapView(this@Carban).also { mapview ->
val mapboxMap = mapview.getMapboxMap()
mapboxMap.setCamera(CameraOptions.Builder().zoom(ZOOM).center(TOKYO).build())
mapboxMap.loadStyleUri(Style.MAPBOX_STREETS){mapview.annotations.createCircleAnnotationManager()
.create(CircleAnnotationOptions().withPoint(TOKYO).withCircleColor(Color.RED))}}
binding.container.addView(mapView)
Everything are OK, except zoom level 6 and (11 to 16) that details don't show until come online. after connecting to internet details which related to shown geometry whit selected zoom level are downloaded in cache. But when I downloaded tile in (0 - 16) zoom level, why I can't rendered my tile in offline way completely?