小编Shr*_*van的帖子

如何为使用 mapbox-gl draw 绘制的单个多边形着色?

我正在读取GeoJSON 文件并将多边形(和其他东西)导入 mapbox-gl draw 使用draw.set(geoJSON). 如何通过要素属性中的属性为单个多边形着色。例子:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      //"id": "the most unique id in the world",
      "properties": {
        "class_id": 1
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              79.30961608886719,
              61.57192958204744
            ],
            [
              79.34309005737303,
              61.57192958204744
            ],
            [
              79.34309005737303,
              61.57871162332267
            ],
            [
              79.30961608886719,
              61.57871162332267
            ],
            [
              79.30961608886719,
              61.57192958204744
            ]
          ]
        ]
      }
    },
    {
      "type": "Feature",
      "properties": {
        "class_id": 2
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              79.35201644897461,
              61.58271478278019 …
Run Code Online (Sandbox Code Playgroud)

mapbox mapbox-gl mapbox-gl-js mapbox-gl-draw

6
推荐指数
1
解决办法
4407
查看次数

标签 统计

mapbox ×1

mapbox-gl ×1

mapbox-gl-draw ×1

mapbox-gl-js ×1