Skip to content

Commit

Permalink
Merge pull request #30 from mejackreed/respect-tile-size
Browse files Browse the repository at this point in the history
respect tileSize key from info.json
  • Loading branch information
mejackreed committed Sep 16, 2015
2 parents 31de935 + e449501 commit 05613df
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions leaflet-iiif.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ L.TileLayer.Iiif = L.TileLayer.extend({
if (options.maxZoom) {
this._customMaxZoom = true;
}

// Check for explicit tileSize set
if (options.tileSize) {
this._explicitTileSize = true;
}

options = L.setOptions(this, options);
this._infoDeferred = new $.Deferred();
this._infoUrl = url;
Expand Down Expand Up @@ -128,6 +134,17 @@ L.TileLayer.Iiif = L.TileLayer.extend({
break;
}

// Unless an explicit tileSize is set, use a preferred tileSize
if (!_this.explicitTileSize) {
if (data.tiles) {
// Image API 2.0 Case
_this.options.tileSize = data.tiles[0].width;
} else if (data.tile_width){
// Image API 1.1 Case
_this.options.tileSize = data.tile_width;
}
}

ceilLog2 = function(x) {
return Math.ceil(Math.log(x) / Math.LN2);
};
Expand Down

0 comments on commit 05613df

Please sign in to comment.