summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenry Castro <hcastro@collabora.com>2018-04-16 17:17:08 -0400
committerAndras Timar <andras.timar@collabora.com>2018-09-08 11:31:55 +0200
commite03792456dec486eaad24988d974650fc08e5355 (patch)
tree6a0431f3095c6a914d30b944f4dd6d8badf43cf1
parentloleaflet: add missing Japanese translations (diff)
downloadonline-e03792456dec486eaad24988d974650fc08e5355.tar.gz
online-e03792456dec486eaad24988d974650fc08e5355.zip
loleaflet: fix when document window zooms out until it disappears
Change-Id: If0f7234429130aed47dbc9156fde2e125680638f (cherry picked from commit e25dc8bba06375c375202515e718f56c983f3e45) Signed-off-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--loleaflet/src/layer/tile/TileLayer.js13
1 files changed, 6 insertions, 7 deletions
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c92ab591fd..b5075ef499 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -2157,20 +2157,19 @@ L.TileLayer = L.GridLayer.extend({
},
_fitWidthZoom: function (e, maxZoom) {
+ if (isNaN(this._docWidthTwips)) { return; }
var size = e ? e.newSize : this._map.getSize();
var widthTwips = size.x * this._map.options.tileWidthTwips / this._tileSize;
- maxZoom = maxZoom ? maxZoom : this._map.getZoom();
+ var ratio = widthTwips / this._docWidthTwips;
+ maxZoom = maxZoom ? maxZoom : this.options.maxZoom;
// 'fit width zoom' has no use in spreadsheets, ignore it there
if (this._docType !== 'spreadsheet') {
var crsScale = this._map.options.crs.scale(1);
- if (this._docWidthTwips > 0)
- {
- var ratio = widthTwips / this._docWidthTwips;
- var zoom = this._map.getZoom() + Math.floor(Math.log(ratio) / Math.log(crsScale));
+ var zoom = 10 + Math.floor(Math.log(ratio) / Math.log(crsScale));
- zoom = Math.max(1, zoom);
- zoom = Math.min(maxZoom, zoom);
+ zoom = Math.min(maxZoom, Math.max(1, zoom));
+ if (this._docWidthTwips * this._map.getZoomScale(zoom, 10) < widthTwips) {
this._map.setZoom(zoom, {animate: false});
}
}