LineLayerDescriptor

data class LineLayerDescriptor(var id: String, var source: String, var sourceLayer: String? = null, var paint: LineLayerPaint = LineLayerPaint( stroke = StrokePaint() ), var filter: Expression? = null, var stencilOnly: Boolean = false, var useGlRendering: Boolean = true, var timing: LayerTiming? = null, var maskLayerIds: List<String> = emptyList(), var maskLayerId: String? = null, var layerMask: LayerMaskSpec? = null, var stencilLayerMask: StencilLayerMaskSpec? = null) : VectorLayerDescriptor<LineLayerPaint> , LayerEventEmitter

Descriptor for a Mapbox line layer: line strings (and polygon rings when applicable) stroked from a vector or GeoJSON source.

Setup matches other VectorLayerDescriptor types: add the source with com.xweather.mapsgl.map.MapController.addSource, then register this descriptor with com.xweather.mapsgl.map.MapController.addLayer. The runtime implementation is a com.xweather.mapsgl.layers.tile.VectorTileLayer backed by Mapbox’s native line style layer.

Sources

  • Vector tiles: set sourceLayer to the MVT layer name that contains line geometry.

  • GeoJSON: set sourceLayer to null when the whole feature collection should be used.

Paint (paint) is a com.xweather.mapsgl.style.LineLayerPaint wrapping com.xweather.mapsgl.style.StrokePaint; it maps to Mapbox line-color, line-opacity, line-width, line-join, line-cap, and line-miter-limit. Join, cap, and miter limit are also honored when this layer is used as a GLES stencil mask source (road ribbons, custom mask pipelines).

Stencil-only lines: when stencilOnly is true, MapsGL still fetches tiles and builds stencil geometry from this layer’s features, but does not add a visible Mapbox line layer. Use that for mask-only line sources (for example motorways referenced from LayerMaskSpec on a weather layer), analogous to JS layers that exist primarily for mask.layers.

Example (visible road line, then reference its id from a weather layer’s LayerMaskSpec):

controller.addSource(VectorSourceDescriptor(id = "roads", url = roadTileUrlTemplate))
controller.addLayer(
LineLayerDescriptor(
id = "road-motorway",
source = "roads",
sourceLayer = "transportation",
paint = LineLayerPaint(stroke = StrokePaint().apply {
thickness = StyleValue.Constant(5.0)
lineJoin = StyleValue.Constant(LineJoin.MITER)
lineCap = StyleValue.Constant(LineCap.ROUND)
}),
filter = Expression.equals(Expression.get("class"), "motorway"),
),
beforeID = null,
)

// Then mask a weather layer against it. The mask is declared on the weather layer's
// configuration, not as an addWeatherLayer parameter:
val temperature = WeatherService.Temperatures(controller.service)
temperature.layer.layerMask = LayerMaskSpec(
layers = listOf(LayerMaskLayerConfig(id = "road-motorway")),
)
controller.addWeatherLayer(temperature)

See also

Constructors

Link copied to clipboard
constructor(id: String, source: String, sourceLayer: String? = null, paint: LineLayerPaint = LineLayerPaint( stroke = StrokePaint() ), filter: Expression? = null, stencilOnly: Boolean = false, useGlRendering: Boolean = true, timing: LayerTiming? = null, maskLayerIds: List<String> = emptyList(), maskLayerId: String? = null, layerMask: LayerMaskSpec? = null, stencilLayerMask: StencilLayerMaskSpec? = null)

Properties

Link copied to clipboard
open override var filter: Expression?

Optional Mapbox filter expression; narrows which features draw and which contribute to masks.

Link copied to clipboard
open override var id: String

Unique layer id within the map controller (referenced by LayerMaskSpec / StencilLayerMaskSpec when used as a mask).

Link copied to clipboard
open override var layerMask: LayerMaskSpec?

JS-style mask shorthand (mask: { layerIds: [...] }). Resolved to stencilLayerMask when stencilLayerMask is unset. Apple's maskConfiguration maps here / to stencilLayerMask.

Link copied to clipboard
open override var maskLayerId: String?

Single mask layer id shorthand. Lowest precedence among mask fields.

Link copied to clipboard
open override var maskLayerIds: List<String>

List of mask layer ids (JS mask.layerIds). Lower precedence than layerMask.

Link copied to clipboard
open override var paint: LineLayerPaint

Line stroke styling serialized to Mapbox line-* paint properties.

Link copied to clipboard
open override var source: String

Id of an already-added vector or GeoJSON source.

Link copied to clipboard
open override var sourceLayer: String?

MVT layer name, or null for GeoJSON-only usage.

Link copied to clipboard

Advanced custom stencil mask. Takes precedence over layerMask / maskLayerIds / maskLayerId.

Link copied to clipboard
open override var stencilOnly: Boolean

When true, skip registering a visible Mapbox line layer; still drive stencil mesh build. See VectorLayerDescriptor.stencilOnly.

Link copied to clipboard
open override var timing: LayerTiming?

Optional per-layer timing (Apple timing). When non-null, com.xweather.mapsgl.map.MapController.addLayer copies these fields onto the created com.xweather.mapsgl.layers.tile.TileLayer.timing. Null keeps the layer's existing defaults (time-series sources may still enable interval mode).

Link copied to clipboard
open override val type: LayerType

Discriminator matching LayerType.

Link copied to clipboard
open override var useGlRendering: Boolean

When true, eligible fill/line/circle/symbol layers draw via MapsGL GLES instead of Mapbox style layers. MVT sources use com.xweather.mapsgl.renderers.VectorFillLayerRenderer / com.xweather.mapsgl.renderers.VectorLineLayerRenderer / etc. GeoJSON fill, line, circle, symbol, and heatmap layers also support GLES when this flag is set.

Functions

Link copied to clipboard
open override fun off(eventName: String)
Link copied to clipboard
open override fun on(eventName: String, callback: (Any?) -> Unit)
Link copied to clipboard
open override fun trigger(eventName: String, data: Any?)