0
votes

I have a vector source(tileset) uploaded on mapbox studio. I am adding a source with this tileset like :

map.addSource("abc", {
            type: "vector",
            url: "mapbox://RELEVANT_MAP_ID"
        });

then I am trying to add a layer like:

map.addLayer({
    "id": "layer_id",
    "type": "line",
    "source": "abc",
    "source-layer": "source_layer_id",
    "layout": {
        "line-join": "round",
        "line-cap": "round"
    },
    "paint": {
        "line-color": "#ff69b4",
        "line-width": 4
    }
});

When I execute this code I get an error :

Error: Source layer "source_layer_id" does not exist on source "abc" as specified by style layer "terrain-data"

What exactly the source_layer is for ? How do I mention the source layer on source in case of vector tiles ? Is there any way to mention the source layer while creating the tile set?

1
I can't answer your last question as it depends which process you used to create the Tileset (uploading to Mapbox Studio, Tippecanoe, exporting a a Dataset to a Tileset or something else).AndrewHarvey

1 Answers

1
votes

If you open your tileset (the one refereced by your RELEVANT_MAP_ID) in Mapbox Studio you'll see something like this

enter image description here

The source-layer is which layer within that Tileset source you want to create the Style Layer for, so from the screenshot it could be admin, aeroway, airport_label, etc.