Replace map.zoomIn and map.zoomOut by map.zoom(delta)
This commit is contained in:
@@ -26,11 +26,8 @@ ol.interaction.DblClickZoom.prototype.handleMapBrowserEvent =
|
|||||||
mapBrowserEvent.isMouseActionButton()) {
|
mapBrowserEvent.isMouseActionButton()) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
var anchor = mapBrowserEvent.getCoordinate();
|
var anchor = mapBrowserEvent.getCoordinate();
|
||||||
if (mapBrowserEvent.browserEvent.shiftKey) {
|
var delta = mapBrowserEvent.browserEvent.shiftKey ? -4 : 4;
|
||||||
map.zoomOut(anchor);
|
map.zoom(delta, anchor);
|
||||||
} else {
|
|
||||||
map.zoomIn(anchor);
|
|
||||||
}
|
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -27,11 +27,8 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
|||||||
var charCode = keyEvent.charCode;
|
var charCode = keyEvent.charCode;
|
||||||
if (charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0)) {
|
if (charCode == '+'.charCodeAt(0) || charCode == '-'.charCodeAt(0)) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
if (charCode == '+'.charCodeAt(0)) {
|
var delta = (charCode == '+'.charCodeAt(0)) ? 4 : -4;
|
||||||
map.zoomIn();
|
map.zoom(delta);
|
||||||
} else {
|
|
||||||
map.zoomOut();
|
|
||||||
}
|
|
||||||
keyEvent.preventDefault();
|
keyEvent.preventDefault();
|
||||||
mapBrowserEvent.preventDefault();
|
mapBrowserEvent.preventDefault();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-17
@@ -838,28 +838,12 @@ ol.Map.prototype.zoom_ = function(resolution, opt_anchor) {
|
|||||||
* @param {number} delta Delta from previous zoom level.
|
* @param {number} delta Delta from previous zoom level.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.zoomByDelta = function(delta, opt_anchor) {
|
ol.Map.prototype.zoom = function(delta, opt_anchor) {
|
||||||
var resolution = this.constraints_.resolution(this.getResolution(), delta);
|
var resolution = this.constraints_.resolution(this.getResolution(), delta);
|
||||||
this.zoom_(resolution, opt_anchor);
|
this.zoom_(resolution, opt_anchor);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.zoomIn = function(opt_anchor) {
|
|
||||||
this.zoomByDelta(4, opt_anchor);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
|
||||||
*/
|
|
||||||
ol.Map.prototype.zoomOut = function(opt_anchor) {
|
|
||||||
this.zoomByDelta(-4, opt_anchor);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number|undefined} resolution Resolution to go to.
|
* @param {number|undefined} resolution Resolution to go to.
|
||||||
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
|
||||||
|
|||||||
Reference in New Issue
Block a user