小编Cor*_*son的帖子

基于 TEXT 属性的 mapbox 图层填充颜色

是否可以根据文本属性而不是数值来设置填充颜色停止点

例如根据省名填写

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

所以我的目标是:'stops': [['GP', 'YELLOW']]

但是,当如下所示实现时,代码不会呈现任何填充颜色,我已将下面代码中的 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'
        }
      });
Run Code Online (Sandbox Code Playgroud)

properties paint layer fill mapbox-gl-js

3
推荐指数
1
解决办法
2330
查看次数

标签 统计

fill ×1

layer ×1

mapbox-gl-js ×1

paint ×1

properties ×1