I’m probably overlooking something, but I would like to use a variable in a condition to style features with that value. I tried defining it, but no luck. If I enter the value in manually, the styling does work.
Is it possible to use a variable in the conditions?
By the way, the values I’m trying to compare are both strings.
This seems to be related to the types and evaluation of the expressions.
With a definition like
someNewVar: `'${someVar}'`,
(inserting the value (which is a string) into 'quotes'), and the condition using
"${feature['sameVarValue']} === ${someNewVar}",
//-----------------------------^ no quotes ^
it should be possible to achieve the desired result.
Intuitively, one could expect the same result as for your approach, but there seems to be a caveat. Maybe the single quotes in ... === '${someNewVar}' cause it to not do the variable substitution? If this was the case, it would end up comparing the value to the string '${someNewVar}' (insead of the string 'whateverTheValueWas'). But that’s really only a wild guess for now - I’d have to read more about the types, expression evaluation, variable substitution, and escaping rules of the styling language if I had to profoundly explain why it did not work…
Here’s a sandcastle using such a construct, to color certain buildings in the Cesium OSM buildings, based on their material: