2

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

ArcGIS.Imagery/z2/0/x1/0/y2.jpg
ArcGIS.Imagery/z13/2/x2624/1/y1750.jpg

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();
        }
        L.tileLayer.customTiles().addTo(map);

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 at 18:19
  • @TomazicM I am not sure that it is possible to set the cache type with SAS Planet – SERG Nov 7 at 18:42
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
}).addTo(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.