Hi,
I want to add some style inside my map, when i go to the url Map styler | Map Display API and export all the JSON style i can add it with success in my map.
map.setStyle(JsonStyle);
But, i don’t want to pass all the object so i found the property addLayer
. For example, if i change the water fill, i need to add the following code:
this.map.addLayer({
"filter": [
"all",
[
"==",
"category",
"permanent_water"
]
],
"id": "Water - Fill",
"metadata": {"group": "water"},
"paint": {
"fill-color": [
"interpolate",
["linear"],
["zoom"],
3,
"hsl(346,44%,23%)",
6,
"hsl(354,100%,40%)"
]
},
"source": "vectorTiles",
"source-layer": "water",
"type": "fill"
}
)
On my map i don’t have any error, and nothing change. I’m pretty sur it’s related to the source-layer
, because if i inspect the object map, inside the style._layer i don’t have any water layer.
I think this come from the data source tile, on the online style we have 4 poiTile and 4 vectorTile, on my current map i got this:
[
"https://a.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.pbf?key=xxx",
"https://b.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.pbf?key=xxx",
"https://c.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.pbf?key=xxx",
"https://d.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.pbf?key=xx"
]
I have tried other layer, and to understand more about this, but without success.
My goal, is to have exactly the same layer from the online editor and add directly the layers i want with the methods addLayer()
.
Thanks for your help !