簡體   English   中英

如何在圖標顏色的案例表達式中使用 mapbox 案例表達式

[英]How to use mapbox case expression within case expression in icon-color

我正在嘗試在圖標顏色的案例表達式中使用案例表達式。 我的圖標顏色取決於變量的組合。 我嘗試了以下語法但沒有成功。 怎么了? 可能嗎?

"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"]

對於初學者,您需要在 colors ( "#111111" ) 和帶有連字符 ( "icon-color" ) 的屬性名稱周圍加上雙引號。

嘗試這個:

"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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM