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) : 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("roads", vectorSourceDescriptor)
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.eq(Expression.get("class"), Expression.literal("motorway"))
)
)
// controller.addWeatherLayer(..., layerMask = LayerMaskSpec(layers = listOf(LayerMaskLayerConfig(id = "road-motorway"))))

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)

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 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
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 val type: LayerType

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?)