ResourceOptions
extension ResourceOptions
-
init(accessToken:baseUrl:cachePath:assetPath:cacheSize:tileStore:tileStoreEnabled:loadTilePacksFromNetwork:)
Initialize a
ResourceOptions
, used by bothMapView
s andSnapshotter
sNote
If
loadTilePacksFromNetwork
is 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
loadTilePacksFromNetwork
should 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
loadTilePacksFromNetwork
matters less. And if users can’t pan freely, and the app is a navigation app,loadTilePacksFromNetwork
should be enabled to avoid downloading duplicate content.If users can pan freely,
loadTilePacksFromNetwork
should 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
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.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.tileStoreEnabled
Enables or disables tile store usage.
loadTilePacksFromNetwork
Enables or disables tile store packs loading from network; default is
false
. This setting is ignored iftileStoreEnabled
isfalse
-
The size of the cache in bytes
Declaration
Swift
public var cacheSize: UInt64? { get }