How to use nested value in order to use case == operator? Something like:
this.map.setPaintProperty("somelayer", "fill-color",
["case",
["==", ["properties:some_prop"], someval],
"#34c0dd",
"#499bbc"]
where properties is dict:
properties = {
some_prop: 1,
some_prop2: 2,
// and so on
}
I have tried ["properties.some_prop"] and ["properties"]["some_prop"] and that does not work as well.
And how to print that mapbox query like console.log or something?
If properties is just the regular properties field on a GeoJSON object, then you don't mention it explicitly - all those fields are just accessed directly:
this.map.setPaintProperty("somelayer", "fill-color",
["case",
["==", ["get", "some_prop"], someval], "#34c0dd",
"#499bbc"
]);
Assuming #499bbc is the default colour you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With