Mapbox – How to Put Custom XYZ Tile in Mapbox

mapboxtiles

How to put custom tiles xyz raster files example :

http://blablabla.bla/{z}/{x}/{y}.png

I tried to insert it using :

map.addSource('bla.tile',{
        'type': 'raster',
        'tiles': ['http://blablabla.bla/{z}/{x}/{y}.png'],
        'tileSize': 150
    })

map.addLayer({
        'id': 'bla',
        'type': 'raster',
        'source': 'bla.tile'
    })

it works but it overlapp my feature / other shape that load (since it's a basemap).

Best Answer

The second argument to addLayer is the ID of the later to insert before. That way you can control what appears on top see https://docs.mapbox.com/mapbox-gl-js/example/wms/

Though I think what you'll find better is just creating your own style object when you initialise the map with your raster tiles. Then any other layers you add after will go on top.

See https://docs.mapbox.com/mapbox-gl-js/style-spec/ and https://docs.mapbox.com/mapbox-gl-js/example/image-on-a-map/