From 64f8a8fd7e69971d59fd5025a6b80a541b2bfdf6 Mon Sep 17 00:00:00 2001 From: Jack Reed Date: Sat, 29 Aug 2015 10:38:27 -0700 Subject: [PATCH] only allow zoom beyond native if maxZoom param is provided --- examples/iiif-example.js | 3 ++- leaflet-iiif.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/iiif-example.js b/examples/iiif-example.js index 716f26d..d8fb4ec 100644 --- a/examples/iiif-example.js +++ b/examples/iiif-example.js @@ -7,7 +7,8 @@ map = L.map('map', { }); stanfordMlk = L.tileLayer.iiif('https://stacks.stanford.edu/image/iiif/hg676jb4964%2F0380_796-44/info.json', { - attribution: 'Martin Luther King Jr. & Joan Baez march to integrate schools, Grenada, MS, 1966' + attribution: 'Martin Luther King Jr. & Joan Baez march to integrate schools, Grenada, MS, 1966', + maxZoom: 6 }).addTo(map); princetonMap = L.tileLayer.iiif('http://libimages.princeton.edu/loris2/pudl0076%2Fmap_pownall%2F00000001.jp2/info.json', { diff --git a/leaflet-iiif.js b/leaflet-iiif.js index a68e7fe..59fa715 100644 --- a/leaflet-iiif.js +++ b/leaflet-iiif.js @@ -13,6 +13,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({ }, initialize: function(url, options) { + if (options.maxZoom) { + this._customMaxZoom = true; + } options = L.setOptions(this, options); this._infoDeferred = new $.Deferred(); this._infoUrl = url; @@ -133,8 +136,8 @@ L.TileLayer.Iiif = L.TileLayer.extend({ _this.maxNativeZoom = Math.max(ceilLog2(_this.x / _this.options.tileSize), ceilLog2(_this.y / _this.options.tileSize)); - // Enable zooming further than native if needed - if (_this.options.maxZoom && _this.options.maxZoom > _this.maxNativeZoom) { + // Enable zooming further than native if maxZoom option supplied + if (_this._customMaxZoom && _this.options.maxZoom > _this.maxNativeZoom) { _this.maxZoom = _this.options.maxZoom; } else {