Mapbox Studio通过REST API更新样式

时间:2016-09-15 01:53:10

标签: mapbox mapbox-gl-js

我们通过Mapbox Studio创建了数据集,tileset和样式

只有一个彩色层非常简单。

然后我们使用REST API添加了许多层。

例如,(参见:https://www.mapbox.com/api-documentation/#update-a-style

style.json文件有许多通过python脚本生成的新图层。

    "layers": [ 
...
       {"id": "bid_id-WPLNS", "source": "composite", "paint": {"fill-color": "rgba(62,129,54,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WPLNS"], "layout": {"visibility": "visible"}, "type": "fill"},
       {"id": "bid_id-WSTSH", "source": "composite", "paint": {"fill-color": "rgba(17,31,177,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSH"], "layout": {"visibility": "visible"}, "type": "fill"},
       {"id": "bid_id-WSTSQ", "source": "composite", "paint": {"fill-color": "rgba(143,124,110,0.4)"}, "source-layer": "Business_Improvement_Districts", "interactive": true, "filter": ["==", "bid_id", "WSTSQ"], "layout": {"visibility": "visible"}, "type": "fill"},
...

然后我们发出REST HTTP PATCH来更新样式:

  

curl -X PATCH   “https://api.mapbox.com/styles/v1/ryozzopanodex/cistmnflb002l2woxcfbgyl3m?access_token=WRITE-TOKEN-HERE”   --data @ style.json --header“Content-Type:application / json”

结果:

请参阅https://city.tidalforce.org/bid

enter image description here

问题为什么当我访问Mapbox Studio并编辑样式时,我是否看不到REST API创建的图层?

我只看到在Studio中创建的原始图层。如果我编辑并保存,似乎所有REST API创建的图层都将被覆盖。

如果有办法通过Mapbox Studio(我们喜欢的话)编辑新图层,请告知我们。

1 个答案:

答案 0 :(得分:1)

您可能正在使用REST API更新样式的已发布版本,但是当您尝试在Mapbox Studio中编辑样式时,您正在查看该样式的草稿版本。尝试使用'还原草稿上次发布的'列表或样式视图页面中的操作:

revert to last published

然后尝试编辑样式。 Mapbox Studio会自动为所有样式创建草稿,以便用户不会意外破坏生产中使用的样式。一旦您对草稿的更改感到满意,您就可以将草稿更改应用于已发布的样式,并使用'发布'样式编辑器中的按钮。