public struct ResourceOptions
extension ResourceOptions: Hashable
extension ResourceOptions: CustomStringConvertible, CustomDebugStringConvertible
Options to configure access to a resource
The access token to access the resource. This should be a valid, non-empty, Mapbox access token
public var accessToken: String
The base URL. Leave as
nilunless you have a reason to change this.
public var baseURL: URL?
The file URL to the cache. The default,
nil, will choose an appropriate location on the device. The default location is excluded from backups.
public var dataPathURL: URL?
The path to the assets. The default,
nil, uses the main bundle.
public var assetPathURL: URL?
The tile store instance
This setting can be applied only if tile store usage is enabled, otherwise it is ignored.
If not set and tile store usage is enabled, a tile store at the default location will be created and used.
If you create a
ResourceOptions(rather than using
ResourceOptionsManagerto manage one) that uses a custom TileStore, you will need to ensure that the
TileStoreis initialized with a valid access token.
tileStore.setOptionForKey(TileStoreOptions.mapboxAccessToken, value: accessToken)
public var tileStore: TileStore?
Tile store usage mode
public var tileStoreUsageMode: TileStoreUsageMode
.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 disk cache.
.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 disk cache won’t be used as long as the up-to-date tile pack exists in the cache.
public init(accessToken: String, baseURL: URL? = nil, dataPathURL: URL? = nil, assetPathURL: URL? = nil, tileStore: TileStore? = nil, tileStoreUsageMode: TileStoreUsageMode = .readOnly)
Mapbox access token. You must provide a valid token.
Base url for resource requests; default is
Path to database cache; default is
nil, which will create a path in a suitable application directory that is excluded from backups.
Path to assets; default is
nil, which will use the application’s resource bundle.
assetPathis expected to be path to a bundle.
A tile store is only used if
true, otherwise this argument is ignored. If
true, the a default tile store will be created and used.
Enables or disables tile store usage.