fix setMinZoom/setMaxZoom

when view has resolutions property, setMinZoom/setMaxZoom doesn't work.
This commit is contained in:
cs09g
2017-11-28 16:20:26 +09:00
parent 841e79b0e8
commit 466d63ac41
3 changed files with 67 additions and 4 deletions

View File

@@ -6,6 +6,7 @@ goog.require('ol');
goog.require('ol.Object');
goog.require('ol.easing');
goog.require('ol.interaction.Property');
goog.require('ol.math');
/**
@@ -180,6 +181,12 @@ 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 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