Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A custom CRS for Leaflet in order to display mapbox raster tiles
const customCRS = L.extend({}, L.CRS.Earth, {
projection: L.Projection.SphericalMercator,
transformation: (function () {
var scale = 0.5 / (Math.PI * L.Projection.SphericalMercator.R);
return new L.Transformation(scale, 0.5, -scale, 0.5);
scale: function (zoom) {
return 512 * Math.pow(2, zoom);
const map ='map', {
crs: customCRS,
const tileLayer = L.tileLayer(, {
tileSize: 512
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.