Similar to how Leaflet's guide shows how to override L.TileLayer's getTileUrl method in place of your own (and L.GridLayer's createTile method),

I want to know how to extend/override Mapbox-gl's baselayer tiles (as opposed to only using a tile server URL to add in custom tiles).

I'm looking to avoid just adding a layer and instead want to overwrite the baselayer itself.

I saw this issue discussion of customizing RasterTileSource.loadTile and wondered if this was the right direction.

Leaflet's example:

L.TileLayer.Kitten = L.TileLayer.extend({
    getTileUrl: function(coords) {
        var i = Math.ceil( Math.random() * 4 );
        return "https://placekitten.com/256/256?image=" + i;

L.tileLayer.kitten = function() {
    return new L.TileLayer.Kitten();


Your Answer

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

Browse other questions tagged or ask your own question.