简体   繁体   English

如何在表达式中使用属性?

[英]How to use property within expression?

I have a property in my GeoJSON file that is called "bla". 我的GeoJSON文件中有一个称为“ bla”的属性。

"text-field": [
'case',
['!=', ['get', 'bla'], null],
  "{bla}%",
['==', ['get', 'bla'], null],
  " ",
  " ",
],

I would like to display that property within a case expression, which is not working. 我想在案例表达式中显示该属性,但无法正常工作。

If I simply pass: 如果我简单地通过:

"text-field": "{bla}%"

it is working just fine. 它工作正常。

How do I use properties within that case expression? 如何在该case表达式中使用属性?

Thanks 谢谢

Use concat instead placeholder: 使用concat代替占位符:

"text-field": [
  "case", ['!=', ['get', 'bla'], null],
    ["concat", ['get', 'bla'], '%'],
  ['==', ['get', 'bla'], null],
    " ",
  " "
]

[ https://jsfiddle.net/sxma7u68/ ] [ https://jsfiddle.net/sxma7u68/ ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 mapbox表达式中的匹配是完全匹配,如何在表达式中使用模糊匹配 - The match in mapbox expression is an exact match,how to use fuzzy match in the expression mapbox :如何使用向表达式添加静态前缀(或后缀)? - mapbox : how can I use add a static prefix (or suffix) to an expression? 如何在 map 中编写用于输入多列、比较它们的值和触发过滤器的 mapbox 表达式? - How to write mapbox expression for inputting multiple columns, comparing their values and triggering filter within the map? 如何在 Mapbox GL map.setFilter 中使用“in”表达式 - How to use `in` expression in Mapbox GL map.setFilter 在MapBox TileMill Teaser中使用Lambda表达式 - Using Lambda Expression within MapBox TileMill Teaser Mapbox 表达式检查 MGLStyleLayer 的属性并与字符串进行比较 - Mapbox Expression to check property of MGLStyleLayer and compare with string Mapbox GL JS 忽略属性表达式 - Mapbox GL JS ignore property expression 当特征属性是布尔值时,mapbox setFilter 表达式的正确语法是什么 - What is correct syntax for a mapbox setFilter expression when feature property is a boolean 将 icon-translate 属性 function、stops 转换为 mapbox 表达式 - Convert icon-translate property function, stops, to mapbox expression 我可以在 Mapbox 中使用嵌套在“case”中的“in”表达式吗? - Can I use an "in" expression nested inside "case" in Mapbox?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM