pngtile: fix map_bounds
authorTero Marttila <terom@paivola.fi>
Mon, 15 Sep 2014 00:15:51 +0300
changeset 143 22efa9fe73c8
parent 142 9b316e83e9e3
child 144 5b2b866ad0a3
pngtile: fix map_bounds
static/pngtile/map.js
--- a/static/pngtile/map.js	Mon Sep 15 00:10:43 2014 +0300
+++ b/static/pngtile/map.js	Mon Sep 15 00:15:51 2014 +0300
@@ -3,17 +3,24 @@
 
 function map_init (_config) {
     map_config = _config;
-
+    
+    // pixel coordinates
     var bounds = L.latLngBounds(
         L.latLng(-map_config.image_height, 0),
         L.latLng(0, +map_config.image_width)
     );
     
+    // in zoom-scaled coordinates
+    var map_bounds = [
+        [ -(map_config.image_height >> map_config.tile_zoom), 0 ],
+        [ 0, +(map_config.image_width >> map_config.tile_zoom) ], 
+    ];
+
     map = L.map('map', {
         crs: L              .CRS.Simple,
         minZoom:            0,
         maxZoom:            map_config.tile_zoom,
-        maxBounds:          bounds
+        maxBounds:          map_bounds
     });
 
     map.on('move', map_move);