You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mapbox瓦片集创建时非聚合图层属性丢失问题咨询

解决Mapbox CLI创建瓦片集时非聚合图层属性丢失问题

问题根源在于你的recipe.json中非聚合图层locations_unclustered没有显式配置要保留的属性。Mapbox Tileset CLI构建瓦片集时,默认不会自动保留所有自定义属性,必须通过features.attributes字段声明需要保留的属性;而直接上传GeoJSON到数据集时,Mapbox会默认保留所有属性,所以不会出现这个问题。

修改后的recipe.json配置

在locations_unclustered图层下添加features.attributes配置,明确指定要保留的属性(比如你需要的addr:housenumber、addr:street、name等):

{
  "version": 1,
  "layers": {
    "locations_clustered": {
      "minzoom": 0,
      "maxzoom": 14,
      "source": "mapbox://tileset-source/MYNAME/mb-flat-1",
      "features": {
        "attributes": {
          "set": { "count": 1 }
        }
      },
      "tiles": {
        "union": [
          {
            "group_by": [],
            "cluster": true,
            "region_count": 64,
            "aggregate": { "count": "sum" }
          }
        ]
      }
    },
    "locations_unclustered": {
      "minzoom": 15,
      "maxzoom": 16,
      "source": "mapbox://tileset-source/MYNAME/mb-flat-1",
      "features": {
        "attributes": {
          "include": [
            "addr:housenumber",
            "addr:street",
            "name",
            "brand",
            "addr:state",
            "addr:city",
            "addr:postcode",
            "amenity",
            "id"
          ]
        }
      },
      "tiles": {
        "union": [
          {
            "group_by": [],
            "cluster": false
          }
        ]
      }
    }
  }
}

关键说明

  • features.attributes.include:用于指定需要保留的属性列表,把你GeoJSON里需要的属性全部列在这里即可。
  • 如果需要保留所有属性,可以用"include": ["*"],但推荐明确列出需要的属性,减少瓦片体积。

修改完成后,重新通过Mapbox CLI构建瓦片集,15-16级的非聚合图层就会保留你需要的元数据/属性了。

内容的提问来源于stack exchange,提问作者Mattpats

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 15:42:41