I'm using leaflet
with tiles generated by gMapCatcher.
the file names there is totally different.
For example - zoom level 17 in leaflet is level 0 at gMapCatcher.
I need to change the url template
'http://{s}.somedomain.com/blabla/{z}/{x}/{y}.png'
so I can insert the calculations for the right directories
I tried the naive way to write the calculations within the template but it does not work.
I found an answer:
I downloades the leaflet.js (passed it through http://jsbeautifier.org/) and changed the code at getTileUrl and added my custom variables :
getTileUrl: function (t) {
return o.Util.template(this._url, o.extend({
s: this._getSubdomain(t),
z: t.z,
x: t.x,
y: t.y,
z0: 17-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)
}, this.options))
},
and in my script
L.tileLayer('img/tiles/gMapCatcher/{z0}/{x0}/{x1}/{y0}/{y1}.png').addTo(map); //gMapCatcher
L.tileLayer('img/tiles/{z}/{x}/{y}.png').addTo(map);
//other tiles