setPaintProperty

fun setPaintProperty(layerId: String, property: String, value: Any)

Sets a paint style property on a layer at runtime, addressed by key path.

Array entries use bracket notation, matching MapsGL JS. text[0] is the first text paint on a symbol layer, such as a place-name layer:

mapController.setPaintProperty("admin.place_city.text", "text[0].size", 20.0)
mapController.setPaintProperty(layerId, "sample.colorscale", colorScale)

value may be a ready com.xweather.mapsgl.style.StyleValue -- including an com.xweather.mapsgl.style.StyleValue.Expression, so text can scale with zoom -- or a plain Number, Color or hex String, which is wrapped as a constant.

One call covers everything applying a paint change needs, which is what MapsGL JS's setPaintProperty does: it writes the value, lets the paint emit its own PAINT_CHANGE where it has one (so a bar legend follows a sample.colorscale change), asks the renderer to rebuild any GL state that is built once rather than per frame, and invalidates the layer. The equivalent by hand is three steps and easy to get half right.

Supported paths:

sample.drawRange is not supported on sample layers; set it before adding the layer. For the sample and particle paths, names after the first segment are matched case-insensitively, so both sample.colorscale and sample.colorScale resolve.

An unknown layer, malformed path, unsupported property or uncoercible value is logged and ignored rather than throwing.

Parameters

layerId

Target layer id, as returned by addLayer / addWeatherLayer.

property

Key path of the paint field, e.g. "text[0].size".

value

New value to apply. text[n].size / .opacity take a Number or StyleValue<Double>; text[n].color / .outlineColor a Color, hex String or StyleValue<Color>; sample.colorscale a ColorScaleOptions; particle.count an Int; particle.size a Size or Number; particle.speed / .trailsFade a Number; particle.trails a Boolean.