@@ -51,6 +51,7 @@ class TileRegionPack(var name: String, var state: TileRegionPackState = TileRegi
51
51
52
52
// stored in metadata for resume functionality
53
53
var styleURI: String? = null
54
+ var tilesets: List <String > = emptyList()
54
55
var bounds: Geometry ? = null
55
56
var zoomRange: ZoomRange ? = null
56
57
@@ -79,17 +80,20 @@ class TileRegionPack(var name: String, var state: TileRegionPackState = TileRegi
79
80
name: String ,
80
81
state: TileRegionPackState = TileRegionPackState .UNKNOWN ,
81
82
styleURI: String ,
83
+ tilesets: List <String >,
82
84
bounds: Geometry ,
83
85
zoomRange: ZoomRange ,
84
86
metadata: JSONObject
85
- ) : this (name= name, state= state,progress= null , metadata= metadata) {
87
+ ) : this (name= name, state= state, progress= null , metadata= metadata) {
86
88
val rnmeta = JSONObject ()
87
89
rnmeta.put(" styleURI" , styleURI)
88
90
this .styleURI = styleURI
89
91
rnmeta.put(" bounds" , bounds.toJSONObject())
90
92
this .bounds = bounds
91
93
rnmeta.put(" zoomRange" , JSONArray (arrayOf(zoomRange.minZoom, zoomRange.maxZoom)))
92
94
this .zoomRange = zoomRange
95
+ rnmeta.put(" tilesets" , JSONArray (tilesets))
96
+ this .tilesets = tilesets
93
97
this .metadata.put(RNMapboxInfoMetadataKey , rnmeta);
94
98
}
95
99
}
@@ -143,9 +147,11 @@ class RNMBXOfflineModule(private val mReactContext: ReactApplicationContext) :
143
147
val boundsFC = FeatureCollection .fromJson(boundsStr)
144
148
val bounds = convertPointPairToBounds(boundsFC)
145
149
150
+ val tilesets = options.getArray(" tilesets" )?.toArrayList()?.map { it as String } ? : emptyList()
146
151
val actPack = TileRegionPack (
147
152
name = id,
148
153
styleURI = options.getString(" styleURL" )!! ,
154
+ tilesets = tilesets,
149
155
bounds = bounds,
150
156
zoomRange = ZoomRange (
151
157
minZoom = options.getInt(" minZoom" ).toByte(),
@@ -280,30 +286,25 @@ class RNMBXOfflineModule(private val mReactContext: ReactApplicationContext) :
280
286
? : return Result .failure(IllegalArgumentException (" startLoading failed as there is no styleURI in pack" ))
281
287
val metadata = pack.metadata
282
288
? : return Result .failure(IllegalArgumentException (" startLoading failed as there is no metadata in pack" ))
283
-
284
289
val stylePackOptions = StylePackLoadOptions .Builder ()
285
290
.glyphsRasterizationMode(GlyphsRasterizationMode .IDEOGRAPHS_RASTERIZED_LOCALLY )
286
291
.metadata(metadata.toMapboxValue())
287
292
.build()
288
-
289
- val descriptorOptions = TilesetDescriptorOptions .Builder ()
290
- .styleURI(styleURI)
291
- .minZoom(zoomRange.minZoom)
292
- .maxZoom(zoomRange.maxZoom)
293
- .stylePackOptions(stylePackOptions)
294
- .pixelRatio(2.0f )
295
- .build()
296
- val tilesetDescriptor = offlineManager.createTilesetDescriptor(descriptorOptions)
297
-
293
+ val descriptors = getTilesetDescriptors(
294
+ offlineManager = offlineManager,
295
+ styleURI = styleURI,
296
+ minZoom = zoomRange.minZoom,
297
+ maxZoom = zoomRange.maxZoom,
298
+ stylePackOptions = stylePackOptions,
299
+ tilesets = pack.tilesets)
298
300
val loadOptions = TileRegionLoadOptions .Builder ()
299
301
.geometry(bounds)
300
- .descriptors(arrayListOf (tilesetDescriptor) )
302
+ .descriptors(descriptors )
301
303
.metadata(metadata.toMapboxValue())
302
304
.acceptExpired(true )
303
305
.networkRestriction(NetworkRestriction .NONE )
304
306
.averageBytesPerSecond(null )
305
307
.build()
306
-
307
308
var lastProgress: TileRegionLoadProgress ? = null
308
309
val task = this .tileStore.loadTileRegion(
309
310
id, loadOptions,
0 commit comments