Skip to main content

Type conversion and fallbacks

Native libraries, desktop and browsers share one evaluator. to-number and to-color try candidates in order and stop after the first successful conversion. Failure of every candidate is an error. An error while evaluating a candidate expression propagates; paint retains its existing default and warning behavior.

map.setPaintProperty('points', 'circle-radius',
  ['to-number', ['get', 'radius'], 12]);
map.setPaintProperty('points', 'circle-color',
  ['to-color', ['get', 'color'], ['literal', [0, 128, 255, 0.5]]]);
await map.sqs.flush({ render: true });

to-number converts null/false to0 and true to1. Empty or whitespace-only strings become0. Decimal, exponent and unsigned0x/0b/0o strings are supported. Arrays and objects cannot convert. Infinity, NaN and overflow never enter styles; later candidates are tried. Complete ECMAScript nonfinite-number semantics are not claimed.

to-color accepts valid CSS strings or RGB(A) arrays. RGB channels must be finite0–255; alpha must be0–1 and defaults to1 for three elements. Colors retain the existing CSS-string representation; typeof returns string. to-boolean converts null, false,0 and empty strings tofalse, otherwise true.

Syntax follows the public MapLibre conversion specification; SqsMap implements it independently. Raw SDK callers use view.flush(). Device acceptance is recorded separately.