PaintSpec

class PaintSpec(val fillColor: MvtExpression<Color>? = null, val fillOpacity: MvtExpression<Float>? = null, val fillExtrusionHeight: MvtExpression<Float>? = null, val fillExtrusionBase: MvtExpression<Float>? = null, val lineColor: MvtExpression<Color>? = null, val lineWidth: MvtExpression<Float>? = null, val lineOpacity: MvtExpression<Float>? = null, val lineCasingColor: MvtExpression<Color>? = null, val lineCasingWidth: MvtExpression<Float>? = null, val lineGradient: MvtExpression<Color>? = null, val lineDashArray: FloatArray? = null, val shadowMode: ShadowMode = ShadowMode.DISABLED, val textField: String? = null, val textColor: MvtExpression<Color>? = null, val textSize: MvtExpression<Float>? = null, val textHaloColor: MvtExpression<Color>? = null, val textHaloWidth: MvtExpression<Float>? = null, val fontFamily: String? = null, val fontWeight: FontWeight = FontWeight.NORMAL, val textPlacement: MvtStyleRule.LabelPlacement = LabelPlacement.POINT, val textMaxWidth: MvtExpression<Float>? = null, val textUppercase: Boolean = false, val iconImage: MvtExpression<String>? = null, val iconSize: MvtExpression<Float>? = null, val iconOffset: MvtExpression<Float>? = null, val iconAnchor: MvtExpression<String>? = null)

Bundle of zoom-interpolated paint properties for one rule. Fields default to "draw nothing"; supply only what your rule needs and the rest stays inert.

Shape paint (polygons / lines):

  • fillColor (+ optional fillOpacity) → polygon fill

  • lineColor + lineWidth (+ optional lineOpacity) → polygon/line stroke Both shape paint groups can coexist on one rule — a polygon with both fill and outline.

Text paint (point labels):

  • textField → name of the feature property whose value becomes the label text. If null, this rule produces no label. If the property is missing/empty on a given feature, that feature is skipped silently.

  • textColor, textSize → the text glyphs; textSize is in pixels.

  • textHaloColor + textHaloWidth → optional outline behind text for readability over busy backgrounds.

  • fontFamily, fontWeight → platform-resolved (system default if null).

Shape and text paint are independent: a rule with both will produce both renderable types for matching features. In practice text rules apply to POINT features and shape rules to POLYGON/LINESTRING, so the geometryType gate keeps them separate.

Constructors

Link copied to clipboard
constructor(fillColor: MvtExpression<Color>? = null, fillOpacity: MvtExpression<Float>? = null, fillExtrusionHeight: MvtExpression<Float>? = null, fillExtrusionBase: MvtExpression<Float>? = null, lineColor: MvtExpression<Color>? = null, lineWidth: MvtExpression<Float>? = null, lineOpacity: MvtExpression<Float>? = null, lineCasingColor: MvtExpression<Color>? = null, lineCasingWidth: MvtExpression<Float>? = null, lineGradient: MvtExpression<Color>? = null, lineDashArray: FloatArray? = null, shadowMode: ShadowMode = ShadowMode.DISABLED, textField: String? = null, textColor: MvtExpression<Color>? = null, textSize: MvtExpression<Float>? = null, textHaloColor: MvtExpression<Color>? = null, textHaloWidth: MvtExpression<Float>? = null, fontFamily: String? = null, fontWeight: FontWeight = FontWeight.NORMAL, textPlacement: MvtStyleRule.LabelPlacement = LabelPlacement.POINT, textMaxWidth: MvtExpression<Float>? = null, textUppercase: Boolean = false, iconImage: MvtExpression<String>? = null, iconSize: MvtExpression<Float>? = null, iconOffset: MvtExpression<Float>? = null, iconAnchor: MvtExpression<String>? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Optional fill-extrusion-base — height of the building's base above terrain (meters). Defaults to 0 = ground-rooted. Use for upper-floor extrusions (tower on a podium).

Link copied to clipboard

Mapbox fill-extrusion-height — when set, polygon features are extruded as 3D boxes from the ground up to this height (meters). Routed through earth.worldwind.layer.buildings.OsmBuildingsTile. Mutually exclusive with the flat-fill path: features matching a rule with extrusion bypass MvtBatchedPolygonTile.

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

True when this rule has a line casing — emits a second stroke under the line.

Link copied to clipboard

True when this rule emits 3D extruded polygons (e.g. buildings).

Link copied to clipboard

True when this rule has an icon spec.

Link copied to clipboard

True when this rule paints a varying color along the line's arc-length parameter.

Link copied to clipboard

True when this rule has at least one shape paint property set.

Link copied to clipboard

True when this rule has a label text spec.

Link copied to clipboard

One of "center" | "top" | "bottom" | "left" | "right" controlling where on the icon the geographic anchor sits. Defaults to center.

Link copied to clipboard

Mapbox-style icon-image — name of the icon to look up in the layer's sprite atlas. Strings can include {property} placeholders for per-feature substitution (e.g. "poi-{kind}"), matching Mapbox GL's icon-image template form.

Link copied to clipboard

Offset in icon-pixel space, applied to the icon's anchor point. Mapbox's icon-offset is a 2D vector; we accept the X component here for the common case of horizontal text-anchored icons.

Link copied to clipboard

Multiplier applied to the icon's pixel size; defaults to 1.0.

Link copied to clipboard

True iff any of this paint's zoom/expression-driven outputs vary per feature within a single tile — i.e. some expression references feature data (get/has/feature-state/ geometry-type/line-progress). Computed once (lazily) by walking every paint expression's tree; constant literals and ["zoom"] interpolations don't count (zoom is fixed within a tile). When false, MvtVectorLayer resolves this rule's paint ONCE per tile and reuses the result for every matching feature.

Link copied to clipboard

Optional casing stroke — Mapbox's "road shoulder" effect. When set, the layer emits a SECOND line stroke for the same feature at a wider lineCasingWidth in lineCasingColor, painted under the main line. Used for road outlines (white road over dark grey casing), railway double-stripes, etc.

Link copied to clipboard

Casing width in pixels. Should be >lineWidth; the visible casing thickness on either side of the fill line is (lineCasingWidth - lineWidth) / 2.

Link copied to clipboard
Link copied to clipboard

Mapbox line-dasharray — alternating dash + gap lengths in line-width multiples. [2, 2] = 2 units on, 2 off, repeating. [3, 1, 1, 1] = long-short-short pattern.

Link copied to clipboard

Mapbox line-gradient — a color expression that varies along the line's arc-length parameter via ["line-progress"]. The layer subdivides each polyline into GRADIENT_SUBDIVISIONS segments and samples the gradient at each segment's midpoint to produce a piecewise-constant approximation that flows through the existing batched line path (no shader changes). Visually close enough for standard "elevation-tinted route" use; near-instant transitions look slightly stepped at the segment boundaries.

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

Mapbox text-max-width — maximum label width in em units (multiples of font size). When set, buildText inserts \n at the last word boundary before each overflow, producing a multi-line label. Default unset = no wrapping.

Link copied to clipboard

Placement strategy for labels. LabelPlacement.POINT is the default and matches POINT features at their geographic anchor; LabelPlacement.LINE places one label per matching LINESTRING feature at its midpoint, rotated to follow the local tangent. Set via the DSL's text(field) { placement = ... } block.

Link copied to clipboard
Link copied to clipboard

Mapbox text-transform: uppercase — render the label in all caps (country/region convention).

Functions

Link copied to clipboard
fun build(zoom: Int, properties: Map<String, Any?> = emptyMap(), featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): ShapeAttributes
Link copied to clipboard
fun buildCasing(zoom: Int, properties: Map<String, Any?> = emptyMap(), featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): ShapeAttributes?

Resolve the casing-stroke ShapeAttributes for one feature. Returns null if this rule has no casing paint. The result is meant to be emitted as a SEPARATE line shape at a slightly lower z-order than build's result, so the wider casing paints underneath the narrower fill.

Link copied to clipboard
fun buildExtrusion(zoom: Int, properties: Map<String, Any?> = emptyMap(), featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): Pair<Double, Double>?

Resolve (height, base) in metres for one feature; null if extrusion isn't set.

Link copied to clipboard
fun buildGradientColor(zoom: Int, progress: Double, properties: Map<String, Any?> = emptyMap(), featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): Color?

Sample lineGradient at the given progress (arc-length parameter ∈ 0, 1) for one feature. Returns null when the rule has no line-gradient.

Link copied to clipboard
fun buildIcon(zoom: Int, properties: Map<String, Any?>, featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): MvtStyleRule.IconSpec?

Resolve this rule's icon paint for one feature. Returns null when iconImage is unset, or when the resolved icon name (after {property} substitution) is empty. Caller is responsible for looking up the name in an MvtSpriteAtlas.

Link copied to clipboard
fun buildText(zoom: Int, properties: Map<String, Any?>, featureState: Map<String, Any?>? = null, geometryType: MvtGeometryType? = null): MvtStyleRule.LabelSpec?

Resolve the label text + TextAttributes for one feature. Returns null if this rule isn't a text rule (hasText is false), or if the feature has no value for textField, or the value's string form is empty.