Skip to content

Commit

Permalink
Merge pull request #76 from 2SC1815J/master
Browse files Browse the repository at this point in the history
Workaround for use Leaflet-IIIF v2.0.1 with Leaflet v0.7.7
  • Loading branch information
mejackreed authored Sep 21, 2019
2 parents 001934f + feca6d0 commit aedf332
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions leaflet-iiif.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -263,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];
Expand All @@ -280,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;
Expand Down

0 comments on commit aedf332

Please sign in to comment.