2016-09-15 127 views
0

更新Mapbox工作室编辑我们通过Mapbox工作室的风格通过REST API

创建数据,地形设置和风格这是非常简单,只有一个着色层。

然后我们使用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补丁更新的样式:

卷曲-X PATCH “https://api.mapbox.com/styles/v1/ryozzopanodex/cistmnflb002l2woxcfbgyl3m?access_token=WRITE-TOKEN-HERE” --data @ style.json --header“内容类型:应用程序/ JSON”

对于结果:

看到https://city.tidalforce.org/bid

enter image description here

问题为什么当我去Mapbox工作室和编辑风格,我没有看到REST API创建的图层?

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

请让我们知道,如果有编辑通过Mapbox Studio中的新图层的方式(这是我们的爱!)

回答

1

有可能是您正在使用REST API更新款式的发行版,但是当您试图在Mapbox Studio中编辑样式时,您正在查看该样式的草稿版本。尝试使用“还原草案上周公布”从列表或样式视图页行动:

revert to last published

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

+0

就是这样,谢谢! –