ResourceOptions
extension ResourceOptions
-
init(accessToken:baseUrl:cachePath:assetPath:cacheSize:tileStore:tileStoreEnabled:loadTilePacksFromNetwork:)Initialize a
ResourceOptions, used by bothMapViews andSnapshottersNote
If
loadTilePacksFromNetworkis enabled, all tile requests are instead converted to tile pack requests, i.e. the tile pack that includes the request tile will be loaded, and the tile extracted from it. With this option set, no individual tile requests will be made.If disabled, the implementation first checks if a tile pack is already loaded. If that’s the case, the tile will be extracted and returned. Otherwise, the implementation falls back to requesting the individual tile and storing it in the ambient cache.
Whether or not
loadTilePacksFromNetworkshould be enabled depends on a few factors:If Predictive Caching is enabled, there’s a good chance that there are already loaded tile packs in the vicinity of the user, so the cost of
loadTilePacksFromNetworkmatters less. And if users can’t pan freely, and the app is a navigation app,loadTilePacksFromNetworkshould be enabled to avoid downloading duplicate content.If users can pan freely,
loadTilePacksFromNetworkshould be disabled. 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.Tile packs loading from network is disabled by default.
Declaration
Swift
public convenience init(accessToken: String, baseUrl: String? = nil, cachePath: String? = nil, assetPath: String? = nil, cacheSize: UInt64 = (1024*1024*10), tileStore: TileStore? = nil, tileStoreEnabled: Bool = true, loadTilePacksFromNetwork: Bool = false)Parameters
accessTokenMapbox access token. You must provide a valid token.
baseUrlBase url for resource requests; default is
nilcachePathPath to database cache; default is
nil, which will create a path in the application’s “support directory”assetPathPath to assets; default is
nil, which will use the application’s resource bundle.cacheSizeSize of the cache.
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.tileStoreEnabledEnables or disables tile store usage.
loadTilePacksFromNetworkEnables or disables tile store packs loading from network; default is
false. This setting is ignored iftileStoreEnabledisfalse -
The size of the cache in bytes
Declaration
Swift
public var cacheSize: UInt64? { get }
ResourceOptions Extension Reference