ResourceOptions
extension ResourceOptions
-
Initialize a
ResourceOptions
, used by bothMapView
s andSnapshotter
sAttention
If
tileStoreUsageMode
is.readonly
(the default): Tile loading first checks the tile store when requesting a tile: If a tile pack is already loaded, the tile will be extracted and returned. Otherwise, the implementation falls back to requesting the individual tile and storing it in the ambient cache.If
tileStoreUsageMode
is.readAndUpdate
: All tile requests are converted to tile pack requests, i.e. the tile pack that includes the requested tile will be loaded, and the tile extracted from it. In this mode, no individual tile requests will be made.This mode can be useful if the map trajectory is predefined and the user cannot pan freely (e.g. navigation use cases), so that there is a good chance tile packs are already loaded in the vicinity of the user.
If users can pan freely, this mode is not recommended. Otherwise, panning will download tile packs instead of using individual tiles. Note that this means that we could first download an individual tile, and then a tile pack that also includes this tile. The individual tile in the ambient cache won’t be used as long as the up-to-date tile pack exists in the cache.
Declaration
Swift
public convenience init(accessToken: String = CredentialsManager.default.accessToken ?? "", baseUrl: String? = nil, cachePath: String? = nil, assetPath: String? = Bundle.main.resourceURL?.path, cacheSize: UInt64 = (1024*1024*50), tileStore: TileStore? = nil, tileStoreUsageMode: TileStoreUsageMode = .readOnly)
Parameters
accessToken
Mapbox access token. You must provide a valid token.
baseUrl
Base url for resource requests; default is
nil
cachePath
Path to database cache; default is
nil
, which will create a path in the application’s “support directory”assetPath
Path to assets; default is
nil
, which will use the application’s resource bundle.assetPath
is expected to be path to a bundle.cacheSize
Size of the cache.
tileStore
A tile store is only used if
tileStoreEnabled
istrue
, otherwise this argument is ignored. Ifnil
(andtileStoreEnabled
istrue
, the a default tile store will be created and used.tileStoreUsageMode
Enables or disables tile store usage.
-
The size of the cache in bytes
Declaration
Swift
public var cacheSize: UInt64? { get }