TileProvider

fun interface TileProvider(source)

Interface for providing tiles to a TileOverlay.

Implementations can provide tiles from various sources:

  • URLs (via UrlTileProvider)

  • Local storage

  • Dynamically generated content

  • Custom tile rendering

Tile coordinates use the Web Mercator projection (EPSG:3857) with the XYZ tile scheme:

  • x: Tile column (0 to 2^zoom - 1, west to east)

  • y: Tile row (0 to 2^zoom - 1, north to south)

  • zoom: Zoom level (0 = world, 19 = building level)

The map calls getTile on a background thread, so it may block, e.g. to read a file or render the tile. Implement it from Kotlin or Java:

val provider = TileProvider { x, y, zoom ->
if (zoom < 10) TileProvider.NO_TILE else Tile(256, 256, renderTile(x, y, zoom))
}
TileProvider provider = (x, y, zoom) ->
zoom < 10 ? TileProvider.NO_TILE : new Tile(256, 256, renderTile(x, y, zoom));

See also

Inheritors

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract fun getTile(x: Int, y: Int, zoom: Int): Tile?

Returns the Tile for the specified coordinates.