GeoJSONSource

Runtime GeoJSON data source for map layers that consume geographic features (points, lines, polygons).

Instances are created when you call com.xweather.mapsgl.map.MapController.addSource with a com.xweather.mapsgl.sources.source.spec.GeoJSONSourceDescriptor. Retrieve the same instance with com.xweather.mapsgl.map.MapController.getSource and cast to GeoJSONSource to update a remote url, assign in-memory data, or refresh after changes.

Remote URL: set url to a template string. makeDataURL expands {startDate} and {endDate} from timeRange (ISO-style via com.xweather.mapsgl.utils.replaceVars), URL-encodes values, and—when authenticator is an XweatherAuthenticator—merges {accessKey}, {clientId}, {clientSecret} and the documentation segment [CLIENT_ID]_[CLIENT_SECRET] like tile sources. If the descriptor omitted com.xweather.mapsgl.sources.source.spec.GeoJSONSourceDescriptor.authenticator, com.xweather.mapsgl.map.MapController.addSource attaches com.xweather.mapsgl.weather.WeatherService.authenticator automatically.

Inline data: set data to a Mapbox FeatureCollection (for example from FeatureCollection.fromJson(...)). You can use this together with or instead of a remote url, depending on your pipeline.

Events: onLoadStart, onLoadComplete, and related signals fire around load lifecycle (see each property).

See also

Constructors

Link copied to clipboard
constructor(id: String)

Properties

Link copied to clipboard
Link copied to clipboard

Optional attribution string for map credits.

Link copied to clipboard

Optional authenticator for remote requests. When this is an XweatherAuthenticator, credential placeholders in url are expanded in makeDataURL.

Link copied to clipboard
var bounds: LatLonBounds?
Link copied to clipboard
var data: FeatureCollection?

Parsed GeoJSON features served directly by the app, or null when using only url. Assigning a new value notifies onDataChange and pushes geometry to the map style when this source is bound (see pushGeoJsonToMapStyle).

Link copied to clipboard
Link copied to clipboard
open override val eventDispatcher: EventDispatcher
Link copied to clipboard
open override val id: String

Stable identifier matching the descriptor and any layers that reference this source.

Link copied to clipboard
open val isEncoded: Boolean
Link copied to clipboard
Link copied to clipboard
open override var isReady: Boolean

Indicates whether the data source is ready to be used by consuming layers, which may be false if data has not been loaded from a remote source yet or the data has not been fully prepared for rendering.

Link copied to clipboard
Link copied to clipboard
open override val kind: DataSourceKind

type in MapsGL JS

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Dispatched when data or derived features change.

Link copied to clipboard

Dispatched when a load operation finishes successfully.

Link copied to clipboard

Dispatched when a load operation begins.

Link copied to clipboard

Dispatched when metadata loading fails (reserved for future metadata support).

Link copied to clipboard

Dispatched when metadata has been parsed (reserved for future metadata support).

Link copied to clipboard

Dispatched when metadata fetch starts (reserved for future metadata support).

Link copied to clipboard
open override var tileCache: TileCache<DataType>
Link copied to clipboard
open var tileManager: TileRequestManager<VectorData>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override var timeRange: ClosedRange<Date>?

Active time window merged into URL variables as startDate and endDate when building a request URL.

Link copied to clipboard
Link copied to clipboard
var url: String?

Remote GeoJSON endpoint template, or null if the source is driven only by data. Placeholders follow com.xweather.mapsgl.utils.replaceVars (e.g. {startDate}, {endDate}).

Link copied to clipboard

Optional list of valid observation times for time-enabled GeoJSON products (product-specific).

Functions

Link copied to clipboard
open override fun addConsumer(consumer: DataSourceConsumer)

Adds a map layer as a consumer of the data source.

Link copied to clipboard
fun addToAnimationQueue(inputString: String)
Link copied to clipboard
fun adjustDateBySeconds(dateString: String, offsetSeconds: Long): String?

Used by prepareTileRequest() to increment or decremnet the time and reformate it for sources with time offets

Link copied to clipboard
open fun contains(coord: TileCoord): Boolean
Link copied to clipboard
fun <DataType : TileData> TileSource<DataType>.contains(coord: TileCoord): Boolean
Link copied to clipboard
open suspend fun fetchMetadata(startDate: Date?, endDate: Date?): Result<Unit>

Returns the metadata for the source, which can be loaded from a remote source.

Link copied to clipboard
open override fun getMetadataURL(): URL?

Metadata is not implemented for this source type; calling this method throws kotlin.NotImplementedError.

Link copied to clipboard
open fun getTileData(coord: TileCoord): Any?
Link copied to clipboard
fun <DataType : TileData> TileSource<DataType>.init(id: String, authenticator: Authenticator<MediaSession.Token>?)
Link copied to clipboard
fun intervalToURLTime(intervalTime: String): String

convert from \"2025-04-22T03:49:31Z\" to 20250422030000

Link copied to clipboard

Requests clients and the map stack to drop cached geometry for this source after url or data changes. Full cache invalidation is still being wired; call this whenever you mutate URL or feature data.

Link copied to clipboard
fun makeDataURL(variables: Map<String, Any> = emptyMap()): URL?

Builds a resolved HTTP(S) URL from url and the given variables, merged with timeRange bounds and XweatherAuthenticator.appendTileCredentialVariables when applicable. Values are URL-encoded.

Link copied to clipboard
fun makeTileURL(coord: TileCoord, variables: Map<String, Any>?): URL
Link copied to clipboard
Link copied to clipboard
fun onTileError(tile: TileType, error: Error)
Link copied to clipboard
suspend fun parseTile(tile: TileType, data: ByteArray, headers: <Error class: unknown class><Any, Any>?): Bitmap
Link copied to clipboard
inline fun <EventType : Event> EventSource.publisher(eventType: Class<EventType>): Flow<EventType>
Link copied to clipboard
open override fun removeConsumer(layerId: String)

Removes a map layer as a consumer of the data source.

Link copied to clipboard
Link copied to clipboard
open suspend override fun requestTiles(coord: TileCoord, options: TileRequestOptions, currentDate: String, fromAnimation: Boolean, intervals: List<String>?): Any
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
inline suspend fun <EventType : Event> EventSource.subscribe(eventType: Class<EventType>, crossinline handler: (EventType) -> Unit)
Link copied to clipboard