gregallensworth / L.TileLayer.Cordova

Leaflet TileLayer subclass which caches to local filesystem, for Cordova/Phonegap
MIT License
87 stars 25 forks source link

TMS based tiles are wrong #25

Closed karigarweb closed 6 years ago

karigarweb commented 6 years ago

As TMS standard force y value to be caculated in negative, this plugin is producing wrong tile number for y axis.

gregallensworth commented 6 years ago

Good catch. This was not tested with tms: true L.TileLayers, so I missed that.

I'll see what I can do...

karigarweb commented 6 years ago

On getY, following code can convert to TMS based tile number: y = Math.pow(2, z) - y - 1;

Than swap t1_y & t2_y as the values are going to be inverse.

gregallensworth commented 6 years ago

@karigarweb Could you please check out the issue25-tms branch and give it a try? It looks good to me, but I'm away from my work computer for a few days so can't test it thoroughly.

The patch specifically is here: https://github.com/gregallensworth/L.TileLayer.Cordova/blob/a87c01ea160ebd34c6ecd12bf1d88ee5aa70cd5e/src/leaflet-tilelayer-cordova.js#L175-L184

gregallensworth commented 6 years ago

@karigarweb Did you get to check out the issue25-tms version, to confirm that it's working?

karigarweb commented 6 years ago

Yes, everything is working like a charm! Thank you