From e745c633838ed3de56d8532893e8b7934a9a2880 Mon Sep 17 00:00:00 2001 From: cs09g Date: Tue, 28 Nov 2017 16:51:11 +0900 Subject: [PATCH] clamp when resolution is defined --- src/ol/interaction/interaction.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 51625a9eb3..fdc4b83b06 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -181,12 +181,14 @@ ol.interaction.Interaction.zoom = function(view, resolution, opt_anchor, opt_dur ol.interaction.Interaction.zoomByDelta = function(view, delta, opt_anchor, opt_duration) { var currentResolution = view.getResolution(); var resolution = view.constrainResolution(currentResolution, delta, 0); - var resolutions = view.getResolutions(); - resolution = ol.math.clamp( - resolution, - view.getMinResolution() || resolutions[resolutions.length - 1], - view.getMaxResolution() || resolutions[0]); + if (resolution !== undefined) { + var resolutions = view.getResolutions(); + resolution = ol.math.clamp( + resolution, + view.getMinResolution() || resolutions[resolutions.length - 1], + view.getMaxResolution() || resolutions[0]); + } // If we have a constraint on center, we need to change the anchor so that the // new center is within the extent. We first calculate the new center, apply