From d7eaacf9238bf5c22fc95b7aa13bdcce7b264920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Fri, 20 Dec 2019 23:04:09 +0100 Subject: [PATCH 1/2] Small performance improvement by saving the calculated logarithm. --- src/ol/View.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 5fc955d351..1dcbd9ab38 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -976,17 +976,17 @@ class View extends BaseObject { * @return {function(number): number} Value for resolution function. */ getValueForResolutionFunction(opt_power) { - const power = opt_power || 2; + const logPower = Math.log(opt_power || 2); const maxResolution = this.maxResolution_; const minResolution = this.minResolution_; - const max = Math.log(maxResolution / minResolution) / Math.log(power); + const max = Math.log(maxResolution / minResolution) / logPower; return ( /** * @param {number} resolution Resolution. * @return {number} Value. */ function(resolution) { - const value = (Math.log(maxResolution / resolution) / Math.log(power)) / max; + const value = (Math.log(maxResolution / resolution) / logPower) / max; return value; }); } From 33389969ce36c25ba0499a8dfa9a14eeb8967b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Kr=C3=B6g?= Date: Fri, 20 Dec 2019 23:04:55 +0100 Subject: [PATCH 2/2] Limit the ZoomSlider's range to the view's constrained resolution. --- src/ol/View.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ol/View.js b/src/ol/View.js index 1dcbd9ab38..3d3bb4bacd 100644 --- a/src/ol/View.js +++ b/src/ol/View.js @@ -945,7 +945,7 @@ class View extends BaseObject { */ getResolutionForValueFunction(opt_power) { const power = opt_power || 2; - const maxResolution = this.maxResolution_; + const maxResolution = this.getConstrainedResolution(this.maxResolution_); const minResolution = this.minResolution_; const max = Math.log(maxResolution / minResolution) / Math.log(power); return ( @@ -977,7 +977,7 @@ class View extends BaseObject { */ getValueForResolutionFunction(opt_power) { const logPower = Math.log(opt_power || 2); - const maxResolution = this.maxResolution_; + const maxResolution = this.getConstrainedResolution(this.maxResolution_); const minResolution = this.minResolution_; const max = Math.log(maxResolution / minResolution) / logPower; return (