Instance Method

loadTile(at:result:)

Loads the specified tile asynchronously.

Declaration

func loadTile(at path: MKTileOverlayPath, result: @escaping (Data?, Error?) -> Void)

Parameters

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. This block is executed on your app’s main thread and takes the following parameters:

  • The tileData parameter contains the raw data loaded from the corresponding image file. You can use this data to initialize an image object. If an error occurred, this parameter is nil.

  • The error parameter contains an error object if there was a problem loading the tile image. If no errors occurred, this parameter is nil.

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 an NSURLConnection 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.

See Also

Customizing the Loading of Tiles

var urlTemplate: String?

The template for generating tile image URLs.

func url(forTilePath: MKTileOverlayPath) -> URL

Returns the URL to use to access the specified tile.

struct MKTileOverlayPath

Use this structure to specify the index values for a single tile.