Add and use ol.Constraints
This commit is contained in:
@@ -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();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user