# HG changeset patch # User Tero Marttila # Date 1412382537 -10800 # Node ID 16ab69a5569ae389485f4461a9696f4c151d22b8 # Parent 58c9e2de0dd47c41ca29e3bdd9f803c7eb0cdb61 pngtile: fix multiple bugs with region-link centering diff -r 58c9e2de0dd4 -r 16ab69a5569a pngtile/tile.py --- a/pngtile/tile.py Sat Oct 04 03:03:17 2014 +0300 +++ b/pngtile/tile.py Sat Oct 04 03:28:57 2014 +0300 @@ -43,7 +43,7 @@ Scale value about center by zoom. """ - return scale(val, zoom) - dim / 2 + return scale(val - dim / 2, zoom) class TileApplication (pngtile.application.PNGTileApplication): # age in seconds for caching an unknown-mtime image for revalidates diff -r 58c9e2de0dd4 -r 16ab69a5569a static/pngtile/map.js --- a/static/pngtile/map.js Sat Oct 04 03:03:17 2014 +0300 +++ b/static/pngtile/map.js Sat Oct 04 03:28:57 2014 +0300 @@ -26,12 +26,16 @@ var map_zoom = map.getZoom(); var size = map.getSize(); + var x = (+map_center.lng) * Math.pow(2, map_config.tile_zoom); + var y = (-map_center.lat) * Math.pow(2, map_config.tile_zoom); + var zoom = map_config.tile_zoom - map_zoom; + var state = { w: size.x, h: size.y, - x: (+map_center.lng) << map_config.tile_zoom, - y: (-map_center.lat) << map_config.tile_zoom, - z: map_config.tile_zoom - map_zoom, + x: x >> zoom, + y: y >> zoom, + z: zoom }; var url = L.Util.template(this.options.url, L.extend(state, this.options));