From a8fc3300b4e1432ec424cf279692851cf0be5a50 Mon Sep 17 00:00:00 2001 From: Aaron Griffith Date: Sat, 5 Apr 2014 20:29:58 -0400 Subject: [PATCH] general fixes for min/maxzoom, documentation cleared up hopeful fix for #1086 --- docs/config.rst | 20 +++++++++++++++----- overviewer_core/data/js_src/util.js | 21 +++++++++++++++++---- overviewer_core/tileset.py | 2 ++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/docs/config.rst b/docs/config.rst index 5d63d21..24067fe 100644 --- a/docs/config.rst +++ b/docs/config.rst @@ -566,13 +566,22 @@ values. The valid configuration keys are listed below. **Default:** ``#1a1a1a`` ``defaultzoom`` - This value specifies the default zoom level that the map will be opened - with. It has to be greater than 0. + This value specifies the default zoom level that the map will be + opened with. It has to be greater than 0, which corresponds to the + most zoomed-out level. If you use ``minzoom`` or ``maxzoom``, it + should be between those two. **Default:** ``1`` ``maxzoom`` - This specifies the maximum zoom allowed by the zoom control on the web page. + This specifies the maximum, closest in zoom allowed by the zoom + control on the web page. This is relative to 0, the farthest-out + image, so setting this to 8 will allow you to zoom in at most 8 + times. This is *not* relative to ``minzoom``, so setting + ``minzoom`` will shave off even more levels. If you wish to + specify how many zoom levels to leave off, instead of how many + total to use, use a negative number here. For example, setting + this to -2 will disable the two most zoomed-in levels. .. note:: @@ -583,8 +592,9 @@ values. The valid configuration keys are listed below. **Default:** Automatically set to most detailed zoom level ``minzoom`` - This specifies the minimum zoom allowed by the zoom control on the web page. For - example, setting this to 2 will disable the two most-zoomed out levels. + This specifies the minimum, farthest away zoom allowed by the zoom + control on the web page. For example, setting this to 2 will + disable the two most zoomed-out levels. .. note:: diff --git a/overviewer_core/data/js_src/util.js b/overviewer_core/data/js_src/util.js index 62bad82..6121cf5 100644 --- a/overviewer_core/data/js_src/util.js +++ b/overviewer_core/data/js_src/util.js @@ -119,7 +119,7 @@ overviewer.util = { zoom = overviewer.mapView.options.currentTileSet.get('minZoom'); } else { zoom = parseInt(zoom); - if (zoom < 0 && zoom + overviewer.mapView.options.currentTileSet.get('maxZoom') >= 0) { + if (zoom < 0) { // if zoom is negative, treat it as a "zoom out from max" zoom += overviewer.mapView.options.currentTileSet.get('maxZoom'); } else { @@ -127,6 +127,13 @@ overviewer.util = { zoom = overviewer.mapView.options.currentTileSet.get('defaultZoom'); } } + + // clip zoom + if (zoom > overviewer.mapView.options.currentTileSet.get('maxZoom')) + zoom = overviewer.mapView.options.currentTileSet.get('maxZoom'); + if (zoom < overviewer.mapView.options.currentTileSet.get('minZoom')) + zoom = overviewer.mapView.options.currentTileSet.get('minZoom'); + overviewer.map.setZoom(zoom); } @@ -512,9 +519,9 @@ overviewer.util = { } - if (zoom == currTileset.get('maxZoom')) { + if (zoom >= currTileset.get('maxZoom')) { zoom = 'max'; - } else if (zoom == currTileset.get('minZoom')) { + } else if (zoom <= currTileset.get('minZoom')) { zoom = 'min'; } else { // default to (map-update friendly) negative zooms @@ -556,7 +563,7 @@ overviewer.util = { zoom = tsetModel.get('minZoom'); } else { zoom = parseInt(zoom); - if (zoom < 0 && zoom + tsetModel.get('maxZoom') >= 0) { + if (zoom < 0) { // if zoom is negative, treat it as a "zoom out from max" zoom += tsetModel.get('maxZoom'); } else { @@ -565,6 +572,12 @@ overviewer.util = { } } + // clip zoom + if (zoom > tsetModel.get('maxZoom')) + zoom = tsetModel.get('maxZoom'); + if (zoom < tsetModel.get('minZoom')) + zoom = tsetModel.get('minZoom'); + overviewer.map.setCenter(latlngcoords); overviewer.map.setZoom(zoom); var locationmarker = new overviewer.views.LocationIconView(); diff --git a/overviewer_core/tileset.py b/overviewer_core/tileset.py index e665bff..032dcdb 100644 --- a/overviewer_core/tileset.py +++ b/overviewer_core/tileset.py @@ -552,7 +552,9 @@ class TileSet(object): poititle = self.options.get("poititle"), showlocationmarker = self.options.get("showlocationmarker") ) + d['maxZoom'] = min(self.treedepth, d['maxZoom']) d['minZoom'] = min(max(0, self.options.get("minzoom", 0)), d['maxZoom']) + d['defaultZoom'] = max(d['minZoom'], min(d['defaultZoom'], d['maxZoom'])) if isOverlay: d.update({"tilesets": self.options.get("overlay")})