I downloaded some tiles from ArcGIS.Imagery with SAS Planet The tiles is in folders like


And I use this TileLayer to display it on Leaflet.

  L.TileLayer.customTiles = L.TileLayer.extend({
            getTileUrl: function (t) {
                console.log('coords', t);
                z = t.z,
                    x = t.x,
                    y = t.y,
                    z0 = t.z,
                    x0 = Math.floor(t.x / 1024),
                    x1 = Math.floor(t.x % 1024),
                    y0 = Math.floor(t.y / 1024),
                    y1 = Math.floor(t.y % 1024)

                const d = `ArcGIS.Imagery/z${z0}/${x0}/x${x1}/${y0}/y${y1}.jpg`;
                console.log('d', d);
                return d;
        L.tileLayer.customTiles = function () {
            return new L.TileLayer.customTiles();

But it looks like there is wrong coordinates. Here is what I got as a result.

Any ideas how to fix it?

enter image description here

  • 1
    Which cache type are you using? It looks like rather complex one. Why don't you go for something simpler, like TMS or or GMT?
    – TomazicM
    Nov 7, 2019 at 18:19
  • @TomazicM I am not sure that it is possible to set the cache type with SAS Planet
    – SERG
    Nov 7, 2019 at 18:42

2 Answers 2


Probably the simplest solution for this is to use TMS tiling schema in SAS Planet, since it's natively supported in Leaflet.

In SAS Planet you go to Settings > Options > Cache. Then in the Default cache type field select Tile Map service (TMS).

The you can declare your TMS layer simply with:

var tmsLayer = L.tileLayer('path to cache files/{z}/{x}/{y}.jpg', {
  tms: true

Get it to work this way:

Using "GlobalMapper Tiles"

L.tileLayer('path to cache files/**z{z}/{y}/{x}**.jpg')

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.