From e9c5d232d586af8f120e6c8f5ca12b34c247fd21 Mon Sep 17 00:00:00 2001 From: 2SC1815J <2SC1815J@users.noreply.github.com> Date: Tue, 16 Jul 2019 16:55:08 +0900 Subject: [PATCH 1/2] fix negative value of _this.maxNativeZoom --- leaflet-iiif.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/leaflet-iiif.js b/leaflet-iiif.js index 4185653..b1b518f 100644 --- a/leaflet-iiif.js +++ b/leaflet-iiif.js @@ -201,8 +201,11 @@ L.TileLayer.Iiif = L.TileLayer.extend({ }; // Calculates maximum native zoom for the layer - _this.maxNativeZoom = Math.max(ceilLog2(_this.x / _this.options.tileSize), - ceilLog2(_this.y / _this.options.tileSize)); + _this.maxNativeZoom = Math.max( + ceilLog2(_this.x / _this.options.tileSize), + ceilLog2(_this.y / _this.options.tileSize), + 0 + ); _this.options.maxNativeZoom = _this.maxNativeZoom; // Enable zooming further than native if maxZoom option supplied From feca6d0c8351d7d74a9ca54063155fce4c87cbbe Mon Sep 17 00:00:00 2001 From: 2SC1815J <2SC1815J@users.noreply.github.com> Date: Tue, 16 Jul 2019 17:00:00 +0900 Subject: [PATCH 2/2] Workaround for use with Leaflet 0.7.7 --- leaflet-iiif.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/leaflet-iiif.js b/leaflet-iiif.js index b1b518f..973b442 100644 --- a/leaflet-iiif.js +++ b/leaflet-iiif.js @@ -72,6 +72,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({ // Set maxZoom for map map._layersMaxZoom = _this.maxZoom; + // Call add TileLayer + L.TileLayer.prototype.onAdd.call(_this, map); + // Set minZoom and minNativeZoom based on how the imageSizes match up var smallestImage = _this._imageSizes[0]; var mapSize = _this._map.getSize(); @@ -91,9 +94,6 @@ L.TileLayer.Iiif = L.TileLayer.extend({ _this._prev_map_layersMinZoom = _this._map._layersMinZoom; _this._map._layersMinZoom = newMinZoom; - // Call add TileLayer - L.TileLayer.prototype.onAdd.call(_this, map); - if (_this.options.fitBounds) { _this._fitBounds(); } @@ -266,7 +266,6 @@ L.TileLayer.Iiif = L.TileLayer.extend({ return this._infoToBaseUrl() + '{region}/{size}/{rotation}/{quality}.{format}'; }, _isValidTile: function(coords) { - var tileBounds = this._tileCoordsToBounds(coords); var _this = this; var zoom = _this._getZoomForUrl(); var sizes = _this._tierSizes[zoom]; @@ -283,6 +282,9 @@ L.TileLayer.Iiif = L.TileLayer.extend({ return true; } }, + _tileShouldBeLoaded: function(coords) { + return this._isValidTile(coords); + }, _getInitialZoom: function (mapSize) { var _this = this; var tolerance = 0.8;