From f3778421b1d5c4695f8ad42d648aa97c310ae3cb Mon Sep 17 00:00:00 2001 From: Ozcan Esen Date: Wed, 6 Jan 2016 12:33:51 +0200 Subject: [PATCH] loleaflet: fix fitWidthZoom inconsistency Change-Id: I511112d05de2b2734d7d2b2f905a3ba797dcca5f --- loleaflet/src/layer/tile/TileLayer.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index b22a0df13..5e2ded111 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -938,17 +938,17 @@ L.TileLayer = L.GridLayer.extend({ if (this._docType !== 'spreadsheet' || !e) { // If it's not a spreadsheet or the method has been invoked manually var crsScale = this._map.options.crs.scale(1); - if (this._docPixelSize.x > size.x) { - var ratio = this._docPixelSize.x / size.x; - var zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); - this._map.setZoom(Math.max(1, this._map.getZoom() - zoomDelta), {animate: false}); - } - else if (size.x / this._docPixelSize.x > crsScale) { + if (size.x / this._docPixelSize.x > crsScale) { // we could zoom in - ratio = size.x / this._docPixelSize.x; - zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); + var ratio = size.x / this._docPixelSize.x; + var zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); this._map.setZoom(Math.min(maxZoom, this._map.getZoom() + zoomDelta), {animate: false}); } + if (this._docPixelSize.x > size.x) { + ratio = this._docPixelSize.x / size.x; + zoomDelta = Math.ceil(Math.log(ratio) / Math.log(crsScale)); + this._map.setZoom(Math.max(1, this._map.getZoom() - zoomDelta), {animate: false}); + } } },