TileOverlay

class TileOverlay(val tileProvider: TileProvider, transparency: Float = 0.0f, zIndex: Float = 0.0f, visible: Boolean = true, fadeIn: Boolean = false, tag: Any? = null)(source)

Represents a tile overlay layer on the map.

Tile overlays display additional tile-based content on top of or below the base map tiles. Common use cases include:

  • Weather overlays (temperature, precipitation, clouds)

  • Transportation overlays (railways, public transit)

  • Outdoor activity overlays (hiking trails, ski pistes)

  • Maritime overlays (nautical charts, depth contours)

  • Custom map styles or data visualizations

Tile overlays use the same 256×256 pixel tiling system as the base map, with tiles loaded dynamically based on the viewport and zoom level.

Example usage:

// Direct instantiation (Kotlin style)
val overlay = TileOverlay(
tileProvider = OpenSeaMapProvider(),
transparency = 0.0f,
zIndex = 1.0f,
visible = true
)
mapView.addTileOverlay(overlay)

// Builder pattern
val overlay = TileOverlayOptions()
.tileProvider(OpenSeaMapProvider())
.transparency(0.0f)
.zIndex(1.0f)
.visible(true)
mapView.addTileOverlay(overlay)

The overlay is a live handle, as returned by OpenMapView.addTileOverlay: setting a property, e.g. overlay.transparency = 0.5f, redraws the map right away and keeps the overlay's downloaded tiles, and remove takes it off the map. Java code uses the getters and setters, e.g. overlay.setTransparency(0.5f).

Parameters

tileProvider

Provider for tile data

transparency

Overlay transparency (0.0 = opaque, 1.0 = fully transparent)

zIndex

Draw order (higher values drawn on top, base tiles are at 0.0)

visible

Whether the overlay is visible

fadeIn

Whether tiles fade in when loaded (currently not implemented)

tag

User data associated with this overlay

See also

Constructors

Link copied to clipboard
constructor(tileProvider: TileProvider, transparency: Float = 0.0f, zIndex: Float = 0.0f, visible: Boolean = true, fadeIn: Boolean = false, tag: Any? = null)

Properties

Link copied to clipboard

Whether tiles fade in when loaded (currently not implemented)

Link copied to clipboard
val id: String

The unique id of this tile overlay, e.g. "to0", which stays the same for its lifetime. copy returns a tile overlay with a new id.

Link copied to clipboard
var tag: Any?

User data associated with this overlay

Link copied to clipboard

Provider for tile data

Link copied to clipboard

Overlay transparency (0.0 = opaque, 1.0 = fully transparent)

Link copied to clipboard

Whether the overlay is visible

Link copied to clipboard

Draw order (higher values drawn on top, base tiles are at 0.0)

Functions

Link copied to clipboard

Drops the downloaded tiles of this overlay, so they are requested again, e.g. after the data behind the tileProvider changed.

Link copied to clipboard
fun copy(tileProvider: TileProvider = this.tileProvider, transparency: Float = this.transparency, zIndex: Float = this.zIndex, visible: Boolean = this.visible, fadeIn: Boolean = this.fadeIn, tag: Any? = this.tag): TileOverlay

Returns a new overlay with the given properties changed, not added to any map.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun remove()

Removes the overlay from the map that shows it.

Link copied to clipboard
open override fun toString(): String