loadTile(at:result:)
Loads the specified tile asynchronously.
Declaration
func loadTile(at path: MKTileOverlayPath, result: @escaping @Sendable (Data?, (any Error)?) -> Void)func loadTile(at path: MKTileOverlayPath) async throws -> DataParameters
- path:
The path structure that identifies the specific tile you want. This structure incorporates the tile’s x-y coordinate at a given zoom level and scale factor.
- result:
The completion block to call when the tile data is available. The method can execute this block on any queue and takes the following parameters:
The
tileDataparameter contains the raw data that loads from the corresponding image file. You can use this data to initialize an image object. If an error occurs, this parameter isnil.The
errorparameter contains an error object if there is a problem loading the tile image. If no errors occur, this parameter isnil.
Discussion
The default implementation of this method uses the url(forTilePath:) method to retrieve the URL for the specified tile and then loads that tile into memory asynchronously using a URLSession object. The specified tile may be located either on the local file system or on a remote server. Subclasses may override this method and implement their own custom tile-loading behavior.
When a tile overlay renderer (that is, an instance of MKTileOverlayRenderer) needs to display tiles, it uses this method to request the data for each tile.