MapController

abstract class MapController(val mapView: MapView, val account: XweatherAccount) : ViewModel, MapProvider, DefaultLifecycleObserver, TileLayer.TileLayerEventListener, ComponentCallbacks2, OnMapClickListener

Bridge between the host map view (Mapbox MapView) and MapsGL: sources, tile layers, timeline, data inspector, legends, and weather APIs.

Use com.xweather.mapsgl.map.mapbox.MapboxMapController as the concrete implementation for Mapbox.

Parameters

mapView

Host MapView; used for context, lifecycle, and dimensions.

account

Xweather credentials used by service and tile requests.

Inheritors

Constructors

Link copied to clipboard
constructor(mapView: MapView, account: XweatherAccount)

Properties

Link copied to clipboard
val account: XweatherAccount
Link copied to clipboard
val animationOptions: AnimationOptions

Configuration options that control the behavior of timeline animations and data preloading.

Link copied to clipboard
lateinit var centerLatLng: Coordinate

Geographic center of the map in latitude/longitude degrees, kept in sync with the camera.

Link copied to clipboard

Pick/inspect weather values at a tap location; enable with addDataInspectorControl.

Link copied to clipboard

Internal debounce job for camera move-end handling; managed by MapboxMapController.

Link copied to clipboard

Approximate download progress fraction (0f–1f) while tiles are in flight.

Link copied to clipboard

All MapsGL map layers currently registered on this controller, keyed by layer id.

Link copied to clipboard

Optional UI control for layer legends; install with add.

Link copied to clipboard
val mapView: MapView
Link copied to clipboard

Observes encoded-tile metadata keys; when a layer id is emitted, that TileLayer refreshes visible tiles. Attach only if you extend encoded sources; normally the controller wires this internally.

Link copied to clipboard

Posted when the current load session completes (encoded downloads and bind pipeline idle).

Link copied to clipboard

Emits MapLoadProgress while map data loads. Use onLoadProgress.observe(this) { progress -> ... } like other LiveData on this controller. For coroutine / flow access, see onLoadProgressValue.

Link copied to clipboard

Same progress as onLoadProgress, exposed as a Signal for coroutine collectors.

Link copied to clipboard

Posted when loading begins for any tracked data source (e.g. tile wave started).

Link copied to clipboard

Fires with a source id after addSource registers it and the source is ready for layers.

Link copied to clipboard

The primary interface for communicating with the Xweather backend.

Link copied to clipboard
Link copied to clipboard

instance used for managing animation and time-based data.

Link copied to clipboard

Library-internal: at least one visible layer is waiting on tile data.

Link copied to clipboard

Library-internal: edge detection for post-download refresh.

Link copied to clipboard

Library-internal: previous frame had pending tile downloads.

Functions

Link copied to clipboard
fun add(legendControl: LegendControl?)

Installs the provided legend control, wiring it to map events and populating initial legends.

open fun add(layerID: String, layerHost: CustomLayerHost)

Hook for map SDK–specific registration of a custom layer host after MapsGL created the layer.

Link copied to clipboard
open fun addCloseable(closeable: AutoCloseable)
fun addCloseable(key: String, closeable: AutoCloseable)
Link copied to clipboard

Activates and initializes the Data Inspector control for the map.

Link copied to clipboard
fun <P : LayerPaint> addLayer(descriptor: LayerDescriptor<P>, beforeID: String?): TileLayer?

Adds a new layer to the map.

Link copied to clipboard
fun addLegend(forConfig: WeatherLayerConfiguration<*, *>)

Adds or refreshes the legend defined on forConfig into the current legendControl.

Link copied to clipboard

Registers a data source. When the descriptor leaves ImageSourceDescriptor.authenticator / EncodedSourceDescriptor.authenticator / VectorSourceDescriptor.authenticator / GeoJSONSourceDescriptor.authenticator unset, this controller supplies service.authenticator automatically.

Link copied to clipboard
fun addWeatherLayer(layerCode: LayerCode, id: String? = null, beforeId: String? = null): TileLayer?

Adds a weather layer from a LayerCode preset (source + descriptor + paint from service).

fun addWeatherLayer(config: WeatherConfiguration, id: String? = null, beforeId: String? = null, isCompoundLayer: Boolean = false): TileLayer?

Adds a weather layer from an explicit WeatherConfiguration (use when you built the config from WeatherService factories instead of LayerCode).

Link copied to clipboard
open override fun getBearing(): Double

Returns the map's current rotational bearing in degrees, if supported. A bearing of 0 orients the map so that north is up.

Link copied to clipboard
open override fun getBounds(): LatLonBounds

Visible geographic bounds in latitude/longitude (implementation wraps Mapbox camera).

Link copied to clipboard
open override fun getCenter(): Coordinate

Returns the map's geographical center coordinate.

Link copied to clipboard
Link copied to clipboard

Resolves the WeatherConfiguration that would be used for addWeatherLayer with this layerCode.

Link copied to clipboard
open override fun getFov(): Double

Returns the map camera's current field-of-view in degrees.

Link copied to clipboard
fun getLayer(id: String): MapLayer<*, *>?
Link copied to clipboard
open override fun getPitch(): Double

Returns the map's current pitch/tilt in degrees, if supported.

Link copied to clipboard
open override fun getSize(): Size

Returns the map's container size.

Link copied to clipboard
Link copied to clipboard

West/east longitude in degrees for tile enumeration (may lie outside -180, 180 when the camera shows several world copies). Defaults to getBounds; Mapbox uses raw unwrapped bounds so encoded layers can render every visible copy.

Link copied to clipboard

Returns A layer given its LayerCode.

Link copied to clipboard
open override fun getZoom(): Double

Returns the map's current zoom level.

Link copied to clipboard
Link copied to clipboard

Returns whether the map currently contains a data source with the specified identifier.

Link copied to clipboard

Returns whether the map currently contains a weather layer with the specified identifier.

Link copied to clipboard
open fun moveLayer(id: String, beforeId: String?)

Reorders an existing layer in the host map style.

Link copied to clipboard
open override fun off(name: String, callback: (Any) -> Unit)

Removes a previously registered callback for name.

Link copied to clipboard
open override fun on(name: String, callback: (Any) -> Unit)

Registers callback for controller-issued events named name (see MapControllerEvents).

Link copied to clipboard
Link copied to clipboard
open override fun onCreate(owner: LifecycleOwner)
Link copied to clipboard
open override fun onDestroy(owner: LifecycleOwner)
Link copied to clipboard
abstract fun onLowMemory()
Link copied to clipboard
open override fun onMapClick(point: Point): Boolean

Mapbox map click: forwards to the data inspector when it is enabled.

Link copied to clipboard
open fun onPause(owner: LifecycleOwner)
Link copied to clipboard
open fun onResume(owner: LifecycleOwner)
Link copied to clipboard
open fun onStart(owner: LifecycleOwner)
Link copied to clipboard
open fun onStop(owner: LifecycleOwner)
Link copied to clipboard
abstract fun onTileLayerEvent(layerId: String, eventType: TileLayer.TileLayerEventType, data: Any? = null)
Link copied to clipboard
abstract fun onTrimMemory(p0: Int)
Link copied to clipboard

Triggers a manual pre-fetch of tile animation data.

Link copied to clipboard
suspend fun query(point: Point, layerList: List<String>, onTouch: Boolean = false): <Error class: unknown class><String, FeatureQueryResult>

Queries encoded tile layers and Mapbox vector layers at point for the given layer ids.

Link copied to clipboard
suspend fun refreshVisibleLayers(requestDL: Boolean = true)

Recomputes visible tiles for every visible MapsGL layer and marks custom layer hosts dirty.

Link copied to clipboard

Deactivates the Data Inspector control and cleans up its associated resources.

Link copied to clipboard
fun removeLayer(id: String, isCompounLayer: Boolean = false)

Removes a layer by id, detaches consumers, and cleans encoded-grid sidecars when present.

Link copied to clipboard

Removes the currently installed legend control and clears any associated observers.

Link copied to clipboard

Unregisters a data source from this controller (does not remove layers that still reference it).

Link copied to clipboard

Removes the weather layer(s) for code from the map, sources, legends, and mask sidecars as needed.

Link copied to clipboard
open fun setCenter(center: Coordinate)

Sets the map's geographical center coordinate.

Link copied to clipboard
open fun setLayerHostToUpdate(layerId: String)

Marks the custom layer host for layerId so textures/uniforms are uploaded on the next draw pass.

Link copied to clipboard
open fun setLayerVisible(id: String, visible: Boolean = true)

Toggles visibility of a MapsGL layer by id and triggers a redraw.

Link copied to clipboard
fun setPaintProperty(layerId: String, property: String, value: Any)

Sets a paint-related property on a layer (reserved for future Mapbox style parity; not fully implemented).

Link copied to clipboard

Shows or hides every map layer (and optional legend) belonging to code, including composite children.

Link copied to clipboard
open fun setZoom(zoom: Double)

Sets the map's zoom level.

Link copied to clipboard
fun trigger(type: String, data: Any? = null)

Dispatches a named event to listeners registered with on for type.