StyleValue

sealed class StyleValue<out T>

Paint or layout property value: either a constant literal or a Mapbox-style expression.

MapsGL uses StyleValue anywhere a style property can be static or data-driven (for example StrokePaint.thickness, colors in FillPaint, or zoom interpolation). Constants serialize to JSON literals; StyleValue.Expression variants serialize to Mapbox expression arrays/objects via com.xweather.mapsgl.style.Expression.toJSONObject.

Use Constant for fixed values known at compile time. Use StyleValue.Expression (or fromExpressionArray) when the value should follow feature data, zoom, or other runtime inputs, matching the JavaScript SDK’s expression arrays.

Parameters

T

Type of the value held by Constant (covariant; StyleValue.Expression uses Nothing because it does not carry a single Kotlin-typed literal).

See also

Inheritors

Types

Link copied to clipboard
object Companion
Link copied to clipboard
data class Constant<T>(val value: T) : StyleValue<T>

A single literal value written directly into style JSON (not wrapped in an expression operator).

Link copied to clipboard
data class Expression(val expression: Expression) : StyleValue<Nothing>

A Mapbox-compatible expression tree (e.g. ["get", "mag"], ["interpolate", ...]).

Properties

Link copied to clipboard

The Constant.value when this is a Constant; otherwise null.

Link copied to clipboard
Link copied to clipboard

JSON-ready representation: constants pass through makeJSONObject, expressions through com.xweather.mapsgl.style.Expression.toJSONObject. Useful for debugging or custom style serialization.