How to put custom tiles xyz raster files example :


I tried to insert it using :

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

        'id': 'bla',
        'type': 'raster',
        'source': 'bla.tile'

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


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/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.