Properties 基于文本特性的mapbox图层填充颜色

Properties 基于文本特性的mapbox图层填充颜色,properties,paint,layer,fill,mapbox-gl-js,Properties,Paint,Layer,Fill,Mapbox Gl Js,可以基于文本属性而不是数字值设置填充颜色停止 e、 g根据省名填写 我的输入数据集有一个名为PROV_ID的属性/列,每个州/省包含一个2个字母的ID 所以我的目标是“停止”:[GP',黄色]] 但是,当按如下所示实现时,代码不会呈现任何填充颜色,我已将下面代码中的PROV_ID替换为要测试的主键属性[numeric],这很好 我想问题是如果填充颜色停止仅限于数字属性 map.addLayer({ 'id': 'countiesLayer', 'type': 'f

可以基于文本属性而不是数字值设置填充颜色停止

e、 g根据省名填写

我的输入数据集有一个名为PROV_ID的属性/列,每个州/省包含一个2个字母的ID

所以我的目标是“停止”:[GP',黄色]]

但是,当按如下所示实现时,代码不会呈现任何填充颜色,我已将下面代码中的PROV_ID替换为要测试的主键属性[numeric],这很好

我想问题是如果填充颜色停止仅限于数字属性

map.addLayer({
        'id': 'countiesLayer',
        'type': 'fill',    /*define the type of layer fill, line, point, fill-extrusion, background, raster, circle*/
        'source': 'mySrcName',
        'source-layer': '3_Fields-83vr21',
        'layout': {
          'visibility': 'visible'
        },

        /*there are many options for styling - this is a simple style*/
        'paint': {
          'fill-color': {
            'property': 'PROV_ID',
            'stops': [['GP', 'YELLOW']]
          },
          'fill-outline-color': 'white'
        }
      });

我想你需要一个带函数的表达式

代码将(未测试):

从文档中:

匹配

选择标签值与输入值匹配的输出,或 未找到匹配项时的回退值。输入可以是任何字符串 或数字表达式(例如:[“get”,“building_type”])。每个标签都可以 可以是单个文字值,也可以是值数组

["match",
input: InputType (number or string),
label_1: InputType | [InputType, InputType, ...], output_1: OutputType,
label_n: InputType | [InputType, InputType, ...], output_n: OutputType, ...,
default: OutputType ]: OutputType
["match",
input: InputType (number or string),
label_1: InputType | [InputType, InputType, ...], output_1: OutputType,
label_n: InputType | [InputType, InputType, ...], output_n: OutputType, ...,
default: OutputType ]: OutputType