Mapbox:如何生成矢量类型的源URL

时间:2019-06-13 07:44:33

标签: mapbox mapbox-gl-js

我正在尝试将源添加到地图中,但是不知道如何生成网址。确实检查了文档,该文档显示:

map.addSource('counties', {
  "type": "vector",
  "url": "mapbox://mapbox.82pkq93d" **<--------------- How to generate this URL?**
  });

我尝试使用以下URL上的export tileet生成map-id:

https://studio.mapbox.com/datasets/

map.on('load', function() {
  map.addSource('counties', {
  "type": "vector",
  "url": "mapbox://mapbox.82pkq93d"
  });
  map.addLayer({
            "id": "water",
            "type": "fill",
            "source": "composite",
            "source-layer": "water",
            "filter": ["all"],
            "layout": {},
            "paint": {"fill-color": "hsl(205, 76%, 70%)"},
            "properties" : {"COUNTY":"Ashland County","FIPS":55003,"median-income":39172,"population":16065} **<--- This has to be present in the source and not layer.**
        })
}

只需要自己生成URL,这样我就可以在GeoJson中添加属性部分

1 个答案:

答案 0 :(得分:1)

您可以在mapbox studio中获取该网址。每个源/数据集附近都有一个链接,您可以在代码中复制和引用该链接。