Skip to content

Commit

Permalink
Merge pull request #27 from mejackreed/fix-zoom-issue
Browse files Browse the repository at this point in the history
only allow zoom beyond native if maxZoom param is provided
  • Loading branch information
eliotjordan committed Aug 31, 2015
2 parents 327d42a + 64f8a8f commit ebb60ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/iiif-example.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<a href="http://searchworks.stanford.edu/view/hg676jb4964">Martin Luther King Jr. & Joan Baez march to integrate schools, Grenada, MS, 1966</a>'
attribution: '<a href="http://searchworks.stanford.edu/view/hg676jb4964">Martin Luther King Jr. & Joan Baez march to integrate schools, Grenada, MS, 1966</a>',
maxZoom: 6
}).addTo(map);

princetonMap = L.tileLayer.iiif('http://libimages.princeton.edu/loris2/pudl0076%2Fmap_pownall%2F00000001.jp2/info.json', {
Expand Down
7 changes: 5 additions & 2 deletions leaflet-iiif.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit ebb60ff

Please sign in to comment.