I have a map, where I am using EPSG:25832 as CRS, and I am trying to add a tilelayer, which needs to get tileinformation in EPSG:3857 CRS - let me elaborate on that:

The source, from where I retrieve my data, has an URL, in this format "x={x}&y={y}&z={z}". So, I am trying to convert the data I have, in the "getTileUrl", which I am overriding.

I have tried using the functions specified here: https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#ECMAScript_.28JavaScript.2FActionScript.2C_etc..29 in the hope of calculating the tileinformation in that manner.

I did somewhat get it to work, by doing the following:

         baseLayers['dotLayer'].getTileUrl = function (tilePoint) {
         var toRet;
         var newPoint = L.point([tilePoint.x, tilePoint.y]);
         var _x = LeafletMap.containerPointToLatLng(newPoint);
         //long2tile(lon,zoom)
         var _newX = parseInt(Math.floor( (_x.lng + 180) / 360 * (1<<tilePoint.z) ));
         //lat2tile(lat,zoom)
         var _newY = parseInt(Math.floor( (1 - Math.log(Math.tan(_x.lat.toRad()) + 1 / Math.cos(lat.toRad())) / Math.PI) / 2 * (1<<tilePoint.z) ));
            toRet = L.Util.template(this._url, L.extend({
                s: this._getSubdomain(tilePoint),
                x: _newX,
                y: _newY,
                z: tilePoint.z
            }, this.options));

            return toRet;
        }

I also tried the "tile2long / tile2lat"-functions, but I could not find out how to use result correctly in proj4js, or find out how to use the result from that...

Sadly, this results in me getting something back, but not what I wished for: I am getting the same tile in each tile, if that makes any sense?

So, my question is, how will I make this work as intended? Kindly let me know, if I am not supplying all info needed - and no, I can not change it to a WMS, sadly.

Best regards.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.