VectorTileLayer

open class VectorTileLayer(var id: String, var source: TileSource<TileData>, var paint: VectorLayerPaint, var tileLayerRenderer: TileLayerRenderer<TileData, LayerRenderContext<Any>>, var zoomOffset: Int, val externalScope: CoroutineScope) : TileLayer

VectorTileLayer.kt

Author

Jason Suto 5/26/25

Constructors

Link copied to clipboard
constructor(id: String, source: TileSource<TileData>, paint: VectorLayerPaint, tileLayerRenderer: TileLayerRenderer<TileData, LayerRenderContext<Any>>, zoomOffset: Int, externalScope: CoroutineScope)

Properties

Link copied to clipboard
open override var alpha: Float

Opacity multiplier applied to this layer's rendered output, from 0 (fully transparent) to 1 (fully opaque).

Link copied to clipboard

Tile coordinates already queued for download by requestVisibleTiles this session.

Link copied to clipboard
open override var animator: TimeSeriesAnimator<Data>?

The time-series animator driving this layer's timeline playback, if timing is configured.

Link copied to clipboard

The current visible geographic bounds for this layer, kept in sync with the map camera by onMove/onMoveEnd. Also used by renderers (e.g. gridded sidecar sampling) as a fallback source of the visible bounds when the map controller isn't directly reachable.

Link copied to clipboard

Identifies the weather product/configuration this layer was created for (e.g. a composite layer's shared code).

Link copied to clipboard

Most recently computed visible tile coordinates.

Link copied to clipboard

The most recently computed tile bounds for this layer's viewport.

Link copied to clipboard

Scale factor derived from quality via the internal DataQuality lookup table, applied in zoomForVisibleTiles.

Link copied to clipboard
lateinit var drawContext: Context

Android Context used to build this layer's GL shaders/programs; set in onAdd.

Link copied to clipboard
open override var enabled: Boolean

Whether this layer's current animation date is within its configured valid/showable range.

Link copied to clipboard
Link copied to clipboard
val externalScope: CoroutineScope

Coroutine scope used for this layer's background tile-download and prep work.

Link copied to clipboard
Link copied to clipboard

Optional ISO alpha-2 for COUNTRY base masks.

Link copied to clipboard

GLES stencil base mask kind for this layer (LAND/WATER/TRANSPORTATION/COUNTRY).

Link copied to clipboard

Selects vector draw path. VectorGraphicsBackend.CUSTOM_WEBGL_MESHES draws via com.xweather.mapsgl.renderers.VectorFillLayerRenderer / com.xweather.mapsgl.renderers.VectorLineLayerRenderer in a Mapbox custom GL layer with an invisible hook layer driving tile fetches. VectorGraphicsBackend.MAPBOX_STYLE_SPEC uses native Mapbox fill/line paint.

Link copied to clipboard
Link copied to clipboard

When true, glStencilMaskKind runs first (marine clip), then line-only stencilLayerMask layers are intersected on land (highways on land, not oceans).

Link copied to clipboard
override var id: String

Unique identifier for this layer within the map, used to look it up (e.g. via MapController).

Link copied to clipboard
open override var invertMaskLayer: Boolean

Unimplemented on TileLayer.

Link copied to clipboard
open override var isDirty: Boolean

Whether this layer needs to be redrawn; set via setNeedsUpdate.

Link copied to clipboard

Set by TileLayerRenderer when this layer uses the special multiband p-type radar shader path (currently only for the "conditions.radar.fill" layer), selecting the radar fragment shader/program variant instead of the standard sample-layer one.

Link copied to clipboard

Tile bounds computed prior to the current currentTileBounds.

Link copied to clipboard
open override var layerRenderContext: LayerRenderContext<Any>

The per-frame render state (paint style, renderables, elapsed time, zoom) passed to tileLayerRenderer.

Link copied to clipboard
open override var mapController: MapController?

The map controller this layer is attached to; set by onAdd when the layer is added to the map.

Link copied to clipboard

Reserved for future status/error text alongside code; not currently populated.

Link copied to clipboard
open override var numH: Int

Reserved tile-grid height (row count); not currently populated by this layer.

Link copied to clipboard
open override var numW: Int

Reserved tile-grid width (column count); not currently populated by this layer.

Link copied to clipboard
val oldCoords: List<TileCoord>? = null

Visible tile coordinates prior to the current coords.

Link copied to clipboard
open override var paint: LayerPaint

The paint/style configuration used to render this layer's data.

Link copied to clipboard

Tile bounds computed by the most recent requestVisibleTiles call, retained for later reference.

Link copied to clipboard

Manages this layer's tile download requests, tile cache, and per-source timeline/interval bookkeeping.

Link copied to clipboard

Data quality/resolution to request and render tiles at. Defaults to DataQuality.exact.

Link copied to clipboard
open override var renderer: LayerRenderer<Any>

Unimplemented on TileLayer; the actual GL renderer used is tileLayerRenderer, a more specific TileLayerRenderer type.

Link copied to clipboard
open override var source: TileSource<TileData>

The tile data source this layer downloads and renders tiles from.

Link copied to clipboard

Handlers registered via MapLayer.addSourceEventHandler to react to this layer's data-source events.

Link copied to clipboard
Link copied to clipboard

Optional custom multi-layer stencil mask (JS-style mask.layerIds).

Link copied to clipboard

When true, com.xweather.mapsgl.map.mapbox.MapboxMapController.addToMap does not add a Mapbox vector style layer; geometry is used only for GLES stencil (custom mask coordinator, geo mask paths).

Link copied to clipboard

Whether the tile bounds have changed since they were last checked.

Link copied to clipboard
var tileLayerRenderer: TileLayerRenderer<TileData, LayerRenderContext<Any>>

The GL renderer that builds and draws this layer's tile geometry each frame.

Link copied to clipboard
val tileRequestOptions: TileRequestOptions

HTTP request options (method, headers, reload/pending behavior, radar flag, etc.) used for this layer's tile downloads.

Link copied to clipboard
open override var timeSeries: AnyTimeSeries?

The time series associated with this layer, if any.

Link copied to clipboard
open lateinit override var timing: LayerTiming

This layer's time-series animation configuration (mode, clamp, valid date range, interval count, etc.).

Link copied to clipboard
open lateinit override var type: LayerType

The kind of layer this is (raster, fill, line, symbol, contour, particles, etc.).

Link copied to clipboard
open override val viewport: Viewport?

The map's current viewport, or null if this layer is not attached to a map controller.

Link copied to clipboard
val MapLayer<*, *>.viewport: Viewport?
Link copied to clipboard
open override var visible: Boolean

Whether this layer is shown on the map. Toggle via the layer's show/hide API.

Link copied to clipboard
open override var waitingOnDL: Boolean

Whether this layer is currently waiting on a tile download to complete.

Link copied to clipboard
open override var wasWaitingOnDL: Boolean

Whether this layer was waiting on a tile download as of the previous check.

Link copied to clipboard
var z: Double

Current data/render zoom level for this layer.

Link copied to clipboard

Offset applied to the map's zoom level when computing which tile z/x/y to request and draw for this layer.

Functions

Link copied to clipboard
open fun addSourceEventHandler(event: String, handler: (e: Any?) -> Unit, once: Boolean = false)
Link copied to clipboard

Registers listener to receive this layer's TileLayerEventType events. No-op if already registered.

Link copied to clipboard

Returns the time series data provider to use for animating the layer, if any.

Link copied to clipboard
open override fun getInfoForLocation(lat: Double, lng: Double, zoom: Int): String

Not yet implemented on TileLayer; always returns an empty string.

Link copied to clipboard

Returns the current tile-index bounds (zoom/left/right/top/bottom) covering this layer's visible viewport, recomputing from bounds only when the render bounds are dirty or the zoom tier has changed since the last call.

Link copied to clipboard
suspend fun getVisibleFeatures(): <Error class: unknown class><String, FeatureQueryResult>?

Returns the features from this layer that intersect the current on‑screen viewport.

Link copied to clipboard

Used in TileTimeSeriesDataProvider. Needs testing

open override fun getVisibleTileCoords(latLonBounds: LatLonBounds, tileBounds: TileBounds, zoom: Double, fromGetRenderables: Boolean): List<TileCoord>

Recieves LatLonBounds and zoom level

Link copied to clipboard

True when this layer draws via MapsGL custom GL meshes rather than Mapbox style layers. Used by com.xweather.mapsgl.layers.tile.TileLayer to skip the encoded-tile prefetch path.

Link copied to clipboard
open fun hide()
Link copied to clipboard
open override fun onAdd()

Not yet implemented on TileLayer; simple no-context registration is not used by this layer.

open override fun onAdd(context: RenderContext<Any>, tileLayer: TileLayer, controller: MapboxMapController)

Not yet implemented on TileLayer; this render-context/owning-layer overload is used by renderer classes instead.

open override fun onAdd(context: Context, controller: MapController)

Attaches this layer to controller, wires up its GL renderer, and starts observing the timeline's play/pause state.

Link copied to clipboard
open override fun onClick()

Not yet implemented on TileLayer.

Link copied to clipboard
open override fun onHidden()

Notifies tileLayerRenderer that the layer was hidden and marks it dirty so it updates accordingly.

Link copied to clipboard
open suspend override fun onMove()

Invoked while the map camera is moving (per frame or throttled).

Link copied to clipboard
open suspend override fun onMoveEnd()

Called once a camera movement settles. Re-syncs bounds, and either re-binds already-resident tiles (when a full-range playback load is held resident and the timeline isn't playing) or requests visible tiles for the settled viewport, skipping the request while playback is already handling a coalesced refresh.

Link copied to clipboard
open override fun onMoveStart()

No-op on TileLayer; this layer does not need to react to the start of a camera move.

Link copied to clipboard
suspend fun onMoveUnrestricted()

Like onMove, but always calls requestVisibleTiles for the new bounds, without the playback/zoom-tier gating onMove applies to limit download churn during timeline playback.

Link copied to clipboard
open fun onReady()
Link copied to clipboard
open override fun onRemove()

No-op on TileLayer; there is no GL/listener state here that needs releasing on removal.

Link copied to clipboard
open override fun onResize()

Not yet implemented on TileLayer.

Link copied to clipboard
open fun onSourceMetadata()

Called when the data source's metadata has been loaded.

Link copied to clipboard
open override fun onVisible()

Notifies tileLayerRenderer that the layer became visible and marks it dirty so it redraws.

Link copied to clipboard
suspend fun prefetchVectorTilesForGlRendering(bypassThrottle: Boolean = false, requestBudget: Int = Int.MAX_VALUE, minIntervalMs: Long = GL_PREFETCH_MIN_INTERVAL_MS, priorityIntervalMs: Long? = null)

Warms MVT cache for custom GL mesh layers when CustomGeometrySource has not yet delivered tiles for the current viewport (e.g. fire observation icons on fires_obs).

Link copied to clipboard

Same viewport and coord selection as requestVisibleTiles, but only counts how many new encoded (coord×time) pairs would be queued — no HTTP, no cache or pending-list mutation. Summed across layers in MapController.refreshVisibleLayers to set a fixed download % denominator.

Link copied to clipboard
open override fun prerender(elapsedTime: Double)

Refreshes layerRenderContext's renderables/paint style for this frame, then delegates to tileLayerRenderer.

Link copied to clipboard
inline fun <EventType : Event> EventSource.publisher(eventType: Class<EventType>): Flow<EventType>
Link copied to clipboard
open override fun queryFeatures(zoomVar: Int, latTile: Int, lonTile: Int, latPix: Int, lonPix: Int, queryLon: Double?, queryLat: Double?): MutableList<String>

Queries features for this layer within a given geometry.

Link copied to clipboard
open fun refresh(clear: Boolean = false)

Refreshes the layer by re-rendering it. If a complete refresh is needed including triggering the associated data source to reload, then pass an argument of true when calling the method. Otherwise, existing cached data will be used when the layer is re-rendered.

Link copied to clipboard
fun registerDependentLayer(dependentId: String)
Link copied to clipboard

Unregisters a previously added TileLayerEventListener; no-op if not registered.

Link copied to clipboard
open override fun render(texUnit: <Error class: unknown class><String, Int>, camera: Camera)

Called from LayerHost.render(), calls TileLayerRenderer.draw()

Link copied to clipboard
suspend fun requestVisibleTiles(bounds: LatLonBounds, reload: Boolean = false, fromAnimation: Boolean = false)
Link copied to clipboard
fun schedulePlaybackViewportRefresh(priorityIntervalMs: Long? = null)

Refreshes MVT/triangulation for the current viewport during timeline playback (pan/zoom).

Link copied to clipboard
open override fun setNeedsUpdate(force: Boolean)

Marks this layer dirty so it redraws on the next frame, propagates the request to tileLayerRenderer, and asks mapController to redraw. Does nothing if the layer is currently hidden, unless force is true.

Link copied to clipboard
open fun show()
Link copied to clipboard
inline suspend fun <EventType : Event> EventSource.subscribe(eventType: Class<EventType>, crossinline handler: (EventType) -> Unit)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open suspend override fun update()

Calls requestVisibleTiles(), gets bounds if needed.