ResourceOptions
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
Declaration
Swift
public var accessToken: String -
The base URL. Leave as
nilunless you have a reason to change this.Declaration
Swift
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.Declaration
Swift
public var dataPathURL: URL? -
The path to the assets. The default,
nil, uses the main bundle.Declaration
Swift
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.
Attention
If you create a
ResourceOptions(rather than usingResourceOptionsManagerto manage one) that uses a custom TileStore, you will need to ensure that theTileStoreis initialized with a valid access token.For example:
tileStore.setOptionForKey(TileStoreOptions.mapboxAccessToken, value: accessToken)Declaration
Swift
public var tileStore: TileStore? -
Tile store usage mode
Declaration
Swift
public var tileStoreUsageMode: TileStoreUsageMode -
Initialize a
ResourceOptions, used by bothMapViews andSnapshottersAttention
If
tileStoreUsageModeis.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.If
tileStoreUsageModeis.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.
Declaration
Swift
public init(accessToken: String, baseURL: URL? = nil, dataPathURL: URL? = nil, assetPathURL: URL? = nil, tileStore: TileStore? = nil, tileStoreUsageMode: TileStoreUsageMode = .readOnly)Parameters
accessTokenMapbox access token. You must provide a valid token.
baseUrlBase url for resource requests; default is
nildataPathURLPath to database cache; default is
nil, which will create a path in a suitable application directory that is excluded from backups.assetPathURLPath to assets; default is
nil, which will use the application’s resource bundle.assetPathis expected to be path to a bundle.tileStoreA tile store is only used if
tileStoreEnabledistrue, otherwise this argument is ignored. Ifnil(andtileStoreEnabledistrue, the a default tile store will be created and used.tileStoreUsageModeEnables or disables tile store usage.
-
Declaration
Swift
public static func == (lhs: `Self`, rhs: `Self`) -> Bool -
Declaration
Swift
public func hash(into hasher: inout Hasher) -
Declaration
Swift
public var description: String { get } -
Declaration
Swift
public var debugDescription: String { get }
ResourceOptions Structure Reference