Atlaslog
Atlaslog / Field Notes / Styling & rendering
Field note · Styling & rendering

A style expression of the wrong type hides the entire layer

Quick answer

The layer and its legend are present but no feature is drawn, and the console shows a single warning. A property name was written as a bare string instead of `["get", ...]`, or `fill-opacity` received a string, so type validation rejects the paint and the layer draws nothing.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: Mapbox GL JS 2.15 / 3.x / MapLibre 4.x
Symptom
Checklist
  1. List layer ids from `map.getStyle().layers` and confirm `map.getLayer('districts')` is not undefined
  2. Replace the paint expression with a constant color and see whether features appear
  3. Check whether a property name was written as a bare string instead of `["get", ...]`
  4. Wrap the value in `["to-number", ["get", ...]]` and retest
  5. Confirm the property exists and inspect its type in the source data
Fix

Use array expressions with explicit conversion: `'fill-color': ['interpolate', ['linear'], ['to-number', ['get', 'pop_density']], 0, '#e8f4ff', 5000, '#8ec4ff', 20000, '#1a6fd4']` and `'fill-opacity': ['case', ['==', ['get', 'level'], 'city'], 0.75, 0.45]`.

Code
Error: layers.districts.paint.fill-color: Expected number but found string
  in expression: ["get", "level"]
Error: layers.districts.paint.fill-opacity: "level" is not a valid expression
Watch out
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

Atlaslog (2026). A style expression of the wrong type hides the entire layer. https://www.jingweizhi.com/en/cookbook/style-expression-missing-property.html (accessed 2026-11-03).