mapbox-gl-js
mapbox-gl-js copied to clipboard
case expression returns null instead of fallback
mapbox-gl-js version: 2.9.0
Question
case
fallback value works well for ==
condition, but not >=
if property is not set:
https://observablehq.com/@mourner/mapbox-gl-expression-playground
null
instead of #fallback
:
but it works for ==
:
Can't find where this behaviour is documented: https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/
Am I missing something?
I believe I have the same issue.
This expression renders correctly, ie. the fallback is used for shapes whose INTFLD is not 1 or 3, including nulls.
"fill-color":
["case",
["==", ["get", "INTFLD"], 1],
["rgba", 255, 0, 0, 1],
["==", ["get", "INTFLD"], 3],
["rgba", 0, 255, 0, 1],
["rgba", 255, 255, 0, 0.5]
]
Whereas with this:
"fill-color":
["case",
["all",
[">=", ["get", "INTFLD"], 0],
["<", ["get", "INTFLD"], 2]
],
["rgba", 255, 0, 0, 1],
["all",
[">=", ["get", "INTFLD"], 2],
["<", ["get", "INTFLD"], 3]
],
["rgba", 0, 255, 0, 1],
["rgba", 255, 255, 0, 0.5]
]
the fallback is used, but NOT where INTFLD is null. Shapes with null values render black.
yes, looks like the same bug.