MapCacheConfig
public struct MapCacheConfig
Settings of your MapCache.
-
Each time a tile is going to be retrieved from the server its x,y and z (zoom) values are plugged into this URL template.
Default value
"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.pngWhere
{s}Replaced with one of the subdomains defined insubdomains.{z}Replaced with the zoom level value.{x}Replaced with the position of the tile in the X asis for this zoom level{y}Replaced with the position of the tile in the X asis for this zoom level
See also
Tiles servers in OpenStreetMap wikiSee also
Tiled we maps in wikipediaDeclaration
Swift
public var urlTemplate: String -
Subdomains used on the
urlTemplateDeclaration
Swift
public var subdomains: [String] -
It must be smaller or equal than
maximumZDefault value is 0.
Declaration
Swift
public var minimumZ: Int -
Maximum supported zoom by the tile server
Tiles with a z zoom beyond
maximumZsupported by the tile server will return a HTTP 404 error.Values vary from server to server. For example OpenStreetMap supports 19, but OpenCycleMap supports 22. The maximum value that can be set is
TileCoords.maxZoom(25).Default value: 19. If 0 or negative is set iOS default value (i.e. 21).
Declaration
Swift
public var maximumZ: Int -
Name of the cache A folder will be created with this name all files will be stored in that folder
This is useful if you want to have different caches for different purposes as well as use the same MapCache in different parts of your application.
Default value “MapCache”
Declaration
Swift
public var cacheName: String -
Cache capacity in bytes. When the cache exceeds this size, the least recently used tiles are deleted. By default is infinite (i.e. UINT64_MAX).
Declaration
Swift
public var capacity: UInt64 -
Optional custom base URL for the cache directory.
When set, overrides the default temporary
NSCachesDirectory/DiskCache/path. Useful for permanent storage, for example pointing toapplicationSupportDirectory.Default is
nil, which uses the default temporary cache location (DiskCache.defaultBaseURL()).Example usage:
let appSupport = FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first! config.baseURL = appSupport.appendingPathComponent("MapCacheTiles", isDirectory: true)Declaration
Swift
public var baseURL: URL? -
Tile size of the tile. Default is 256x256
Declaration
Swift
public var tileSize: CGSize -
Load tile mode. Sets the strategy to be used when loading a tile. By default loads from the cache and if it fails loads from the server
See also
LoadTileModeDeclaration
Swift
public var loadTileMode: LoadTileMode -
Constructor with all the default values.
Declaration
Swift
public init() -
Constructor that overwrites the
urlTemplate`Declaration
Swift
public init(withUrlTemplate urlTemplate: String)Parameters
withUrlTemplateis the string of the
urlTemplate -
Selects one of the subdomains randomly.
Declaration
Swift
public func randomSubdomain() -> String? -
Keeps track of the index of the last subdomain requested for round robin
Declaration
Swift
private var subdomainRoundRobin: Int -
Round Robin algorithm If subdomains are a,b,c then it makes requests to a,b,c,a,b,c,a,b,c…
It uniformly makes requests to all the subdomains.
Declaration
Swift
public mutating func roundRobinSubdomain() -> String?
View on GitHub