[英]How to use mapbox case expression within case expression in icon-color
I am trying to have a case expression within case expression in icon-color.我正在尝试在图标颜色的案例表达式中使用案例表达式。 My icon-color depends on a combination of to variables.
我的图标颜色取决于变量的组合。 I tryed the following syntax without any success.
我尝试了以下语法但没有成功。 What is wrong?
怎么了? Is it possible?
可能吗?
"icon-color": [
"case",
["==",["get","status"],"s1"],
["case", ["==",["get","priority"],"p1"], "#111111", ["==",["get","priority"],"p2"], "#222222", "#DDDDDD"]
["==",["get","status"],"s2"],
["case", ["==",["get","priority"],"p1"], "#333333", ["==",["get","priority"],"p2"], "#444444", "#DDDDDD"]
"#777777"]
For starters, you need to put double quotes around your colors ( "#111111"
) and around property names with hyphens ( "icon-color"
).对于初学者,您需要在 colors (
"#111111"
) 和带有连字符 ( "icon-color"
) 的属性名称周围加上双引号。
Try this:尝试这个:
"icon-color": [
"case",
["all",["==",["get","status"],"s1"],["==",["get","priority"],"p1"]], // is status == s1 AND priority == p1?
"#111111", // result of all on the above line being true
["all",["==",["get","status"],"s1"],["==",["get","priority"],"p2"]], // after failing the first test, is status == s1 AND priority == p2?
"#222222", // result of all on the above line being true
["all",["==",["get","status"],"s2"],["==",["get","priority"],"p1"]], // after failing the second test, is status == s2 AND priority == p1?
"#333333", // result of all on the above line being true
["all",["==",["get","status"],"s2"],["==",["get","priority"],"p2"]], // after failing the third test, is status == s2 AND priority == p2?
"#444444", // result of all on the above line being true
"#777777" // result of all tests failing
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.