首页 > 解决方案 > MapBox NumberFormat 预期语法

问题描述

我在 MapBox Studio 上苦苦挣扎

我需要格式化海拔并使用该numberFormat功能。

但是,我没有成功找到正确的语法。文档很差。

到目前为止,我确实尝试过这样做:

number-format(elevation, {'locale':'fr'})

但它一直说语法不正确。尝试双引号,也尝试添加。

我找到了唯一的信息:

使用提供的格式规则将输入数字转换为字符串表示形式。如果设置,“code”参数指定要使用的语言环境,作为 BCP 47 语言标记。如果设置,则货币参数指定用于货币样式格式的 ISO 4217 代码。如果设置,则 min-fraction-digits 和 max-fraction-digits 参数指定要包含的最小和最大小数位数。

Mapbox Studio 尝试使用 NumberFormat 函数

标签: mapboxmapbox-studio

解决方案


使用的正确语法似乎记录在那里:https ://docs.mapbox.com/mapbox-gl-js/example/cluster-html/

根据我的需要,正确的做法是

[
'number-format',
['get', 'elevation'],
{ 'locale': 'fr' }
]

推荐阅读