mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Previously a map tile cache miss would cause 2x loading of the tile: once from the remote tile server (which is then written to disk) and once from disk during the default MKTileOverlay.loadTile function. Instead we now directly implement loadTile so that we can avoid the duplicate loading and simply return the fetched remote tile after it is cached, which leads to a noticeable improvement in offline map performance.
17 lines
368 B
Swift
17 lines
368 B
Swift
//
|
|
// TileOverlay.swift
|
|
// Meshtastic
|
|
//
|
|
// Copyright(c) Garth Vander Houwen 5/5/23.
|
|
//
|
|
|
|
import Foundation
|
|
import MapKit
|
|
|
|
typealias TileCoordinates = (x: Int, y: Int, z: Int)
|
|
|
|
class TileOverlay: MKTileOverlay {
|
|
override func loadTile(at path: MKTileOverlayPath) async throws -> Data {
|
|
return try OfflineTileManager.shared.loadAndCacheTileOverlay(for: path)
|
|
}
|
|
}
|