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}.png

    Where

    1. {s} Replaced with one of the subdomains defined in subdomains.
    2. {z} Replaced with the zoom level value.
    3. {x} Replaced with the position of the tile in the X asis for this zoom level
    4. {y} Replaced with the position of the tile in the X asis for this zoom level

    Declaration

    Swift

    public var urlTemplate: String
  • Subdomains used on the urlTemplate

    Declaration

    Swift

    public var subdomains: [String]
  • It must be smaller or equal than maximumZ

    Default value is 0.

    Declaration

    Swift

    public var minimumZ: Int
  • Maximum supported zoom by the tile server

    Tiles with a z zoom beyond maximumZ supported 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

    Default value: 19. If 0 or negative is set iOS default value (i.e. 21)

    Declaration

    Swift

    public var maximumZ: Int
  • If set to true when zooming in beyond maximumZ the tiles at maximumZ will be upsampled and shown. This mitigates the issue of showing an empty map when zooming in beyond maximumZ.

    maximumZ is vital to zoom working, make sure it is properly set.

    Declaration

    Swift

    public var overZoomMaximumZ: Bool
  • Name of the cache A folder will be created with this name all files will be stored in that folder

    Default value “MapCache”

    Declaration

    Swift

    public var cacheName: String
  • Cache capacity in bytes

    Declaration

    Swift

    public var capacity: UInt64
  • 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

    LoadTileMode

    Declaration

    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

    withUrlTemplate

    is 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?