UrlTileProvider

abstract class UrlTileProvider(urlTemplate: String) : TileProvider(source)

Abstract base class for TileProvider implementations that fetch tiles from URLs.

This class handles HTTP requests and tile downloading, while subclasses provide the URL template and optional customization.

URL templates use placeholders that are replaced with tile coordinates:

  • {z} - Zoom level

  • {x} - Tile column

  • {y} - Tile row

Example usage:

class CustomTileProvider : UrlTileProvider(
urlTemplate = "https://example.com/tiles/{z}/{x}/{y}.png"
) {
override fun getUserAgent(): String {
return "MyApp/1.0"
}
}

See also

Constructors

Link copied to clipboard
constructor(urlTemplate: String)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
fun close()

Closes the HTTP client and releases resources. Should be called when the tile provider is no longer needed.

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

Fetches tile data from the URL for the specified coordinates.

Link copied to clipboard
protected open fun getTileUrl(x: Int, y: Int, zoom: Int): String

Builds the URL for the specified tile coordinates by replacing placeholders in the URL template.

Link copied to clipboard
protected open fun getUserAgent(): String

Returns the User-Agent header to use for HTTP requests. Subclasses can override to provide a custom User-Agent.