1
votes

We created a dataset, tileset, and style via Mapbox Studio

It was very simple with only one colored layer.

Then we used the REST API to add many layers.

For example, (reference see: https://www.mapbox.com/api-documentation/#update-a-style)

The style.json file has many new layers that were generated via a python script.

    "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"},
...

then we issue a REST HTTP PATCH to update the style:

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

For the result:

see https://city.tidalforce.org/bid

enter image description here

Question WHY when I go to Mapbox Studio and edit the style, do I NOT see the REST API created layers?

I only see the original layers that were created in Studio. If I edit and save, it appears that all the REST API created layers would be overwritten.

Please let us know if there is a way to edit the new layers via Mapbox Studio (which we love!)

1

1 Answers

2
votes

it is possible that you are using the REST API to update the published version of the style, but you're viewing the draft version of the style when you attempt to edit the style in Mapbox Studio. Try using the 'revert draft to last published' action from the list or style view page:

revert to last published

and then try to edit the style. Mapbox Studio automatically creates drafts for all styles so that users don't accidentally break styles that are used in production. Once you're satisfied with changes to your draft, you can apply the draft changes to the published style with the 'publish' button in the styl editor.