From aa398e1b7d2f444ba2c66bfcbf1361b74fb03a02 Mon Sep 17 00:00:00 2001 From: perliedman Date: Wed, 6 Aug 2014 09:38:13 +0200 Subject: [PATCH] =?UTF-8?q?Na=C3=AFve=20fix=20for=20non-integer=20zoomleve?= =?UTF-8?q?ls=20in=20CRS.scale;=20interpolation=20results=20in=20discontin?= =?UTF-8?q?uities?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/proj4leaflet.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/proj4leaflet.js b/src/proj4leaflet.js index 77208ca..498111d 100644 --- a/src/proj4leaflet.js +++ b/src/proj4leaflet.js @@ -108,7 +108,21 @@ }, scale: function(zoom) { - return this._scales[zoom]; + var iZoom = Math.floor(zoom), + baseScale, + nextScale, + scaleDiff, + zDiff; + if (zoom === iZoom) { + return this._scales[zoom]; + } else { + // Non-integer zoom, interpolate + baseScale = this._scales[iZoom]; + nextScale = this._scales[iZoom + 1]; + scaleDiff = nextScale - baseScale; + zDiff = (zoom - iZoom); + return baseScale + scaleDiff * Math.pow(zDiff, nextScale / baseScale); + } }, });