CachedTileOverlay

open class CachedTileOverlay : MKTileOverlay

Whenever a tile is requested by the MapView, it calls the MKTileOverlay.loadTile. This class overrides the default MKTileOverlayto provide support to MapCache.

See also

MkMapView+MapCache
  • A class that implements the MapCacheProtocol

    Declaration

    Swift

    let mapCache: MapCacheProtocol
  • If true loadTile uses the implementation of the mapCache var. If false, uses the default MKTileOverlayimplementation from Apple.

    Declaration

    Swift

    public var useCache: Bool
  • Constructor.

    Declaration

    Swift

    public init(withCache cache: MapCacheProtocol)

    Parameters

    withCache

    the cache to be used on loadTile

  • Generates the URL for the tile to be requested. It replaces the values of {z},{x} and {y} in the urlTemplatedefined in mapCache.config

    Declaration

    Swift

    override public func url(forTilePath path: MKTileOverlayPath) -> URL
  • When invoked it will load the tile using the standard OS implementation (if useCacheis false) or from the cache (if useCache is true

    Declaration

    Swift

    override public func loadTile(at path: MKTileOverlayPath,
                                  result: @escaping (Data?, Error?) -> Void)
  • Tells whether or not to upsample and show a lesser detailed z level takes into account useZoom configuration as well as current and maximumZ values

    Declaration

    Swift

    func shouldZoom(at scale: MKZoomScale) -> Bool
  • Given the maximum zoom level for the tileset (mapCache.config.maximumZ) it will return the tile, map rects, and additional scaling factor for upscaling tiles.

    Declaration

    Swift

    func tilesInMapRect(rect: MKMapRect, scale: MKZoomScale) -> [ZoomableTile]

    Parameters

    rect

    map rectangle for which we want to get the tile set

    scale

    current zoom scale