Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for use Leaflet-IIIF v2.0.1 with Leaflet v0.7.7 #76

Merged
merged 2 commits into from
Sep 21, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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