Add and use ol.Constraints

This commit is contained in:
Tom Payne
2012-08-04 15:27:23 +02:00
parent eaca7d0a8c
commit 0fd122a1ed
13 changed files with 163 additions and 147 deletions
+7 -21
View File
@@ -3,26 +3,17 @@ goog.provide('ol.control.DblClickZoom');
goog.require('goog.events.EventType');
goog.require('ol.Control');
goog.require('ol.MapBrowserEvent');
goog.require('ol.control.ResolutionConstraintType');
goog.require('ol.control.Constraints');
/**
* @constructor
* @extends {ol.Control}
* @param {ol.control.ResolutionConstraintType} resolutionConstraint
* Resolution constraint.
* @param {ol.control.Constraints} constraints Constraints.
*/
ol.control.DblClickZoom = function(resolutionConstraint) {
goog.base(this);
/**
* @private
* @type {ol.control.ResolutionConstraintType}
*/
this.resolutionConstraint_ = resolutionConstraint;
ol.control.DblClickZoom = function(constraints) {
goog.base(this, constraints);
};
goog.inherits(ol.control.DblClickZoom, ol.Control);
@@ -34,14 +25,9 @@ ol.control.DblClickZoom.prototype.handleMapBrowserEvent =
function(mapBrowserEvent) {
if (mapBrowserEvent.type == goog.events.EventType.DBLCLICK) {
var map = mapBrowserEvent.map;
map.withFrozenRendering(function() {
// FIXME compute correct center for zoom
map.setCenter(mapBrowserEvent.getCoordinate());
var browserEvent = mapBrowserEvent.browserEvent;
var delta = browserEvent.shiftKey ? -1 : 1;
var resolution = this.resolutionConstraint_(map.getResolution(), delta);
map.setResolution(resolution);
}, this);
var delta = mapBrowserEvent.browserEvent.shiftKey ? -1 : 1;
var anchor = mapBrowserEvent.getCoordinate();
this.zoom(map, delta, anchor);
mapBrowserEvent.preventDefault();
}
};