Animate DragZoom

This commit is contained in:
Antoine Abt
2014-01-03 14:23:22 +01:00
parent 3461b026b6
commit 6dd504dcb2

View File

@@ -2,11 +2,19 @@ goog.provide('ol.interaction.DragZoom');
goog.require('goog.asserts');
goog.require('ol.events.condition');
goog.require('ol.extent');
goog.require('ol.interaction.DragBox');
goog.require('ol.interaction.Interaction');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
/**
* @define {number} Timeout duration.
*/
ol.interaction.DRAGZOOM_ANIMATION_DURATION = 200;
/**
* Allows the user to zoom the map by clicking and dragging on the map,
@@ -47,10 +55,12 @@ goog.inherits(ol.interaction.DragZoom, ol.interaction.DragBox);
* @inheritDoc
*/
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
this.getMap().withFrozenRendering(goog.bind(function() {
// FIXME works for View2D only
var view = this.getMap().getView().getView2D();
view.fitExtent(this.getGeometry().getExtent(), this.getMap().getSize());
}, this));
// FIXME works for View2D only
var map = this.getMap();
var view = map.getView().getView2D();
var extent = this.getGeometry().getExtent();
var center = ol.extent.getCenter(extent);
ol.interaction.Interaction.zoom(map, view,
view.getResolutionForExtent(extent, map.getSize()),
center, ol.interaction.DRAGZOOM_ANIMATION_DURATION);
};