Mapbox gl 表达式
Mapbox gl expressions
我不明白如何使用新的 mapbox 表达式。
例如,如果我需要这样的东西:
如果 prop 'store' 大于 0 且小于 500,则将 circle-radius 设置为 10
如果 prop 'store' 大于 500,则将 circle-radius 设置为 20
如何使用表达式来实现?
谢谢
你可以使用 case 表达式,这个可以做到:
[
'case',
['all', ['>', ['get', 'store'], 0], ['<', ['get', 'store'], 500]],
10,
['>', ['get', 'store'], 500],
20,
0
];
在此处查看文档:https://www.mapbox.com/mapbox-gl-js/style-spec#expressions-case
我不明白如何使用新的 mapbox 表达式。 例如,如果我需要这样的东西:
如果 prop 'store' 大于 0 且小于 500,则将 circle-radius 设置为 10
如果 prop 'store' 大于 500,则将 circle-radius 设置为 20
如何使用表达式来实现? 谢谢
你可以使用 case 表达式,这个可以做到:
[
'case',
['all', ['>', ['get', 'store'], 0], ['<', ['get', 'store'], 500]],
10,
['>', ['get', 'store'], 500],
20,
0
];
在此处查看文档:https://www.mapbox.com/mapbox-gl-js/style-spec#expressions-case