Add drag box in shift drag zoom control
This commit is contained in:
@@ -4,6 +4,7 @@ goog.provide('ol.interaction.ShiftDragZoom');
|
||||
|
||||
goog.require('ol.Extent');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.control.DragBox');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
@@ -27,7 +28,16 @@ ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED =
|
||||
* @extends {ol.interaction.Drag}
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom = function() {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @type {ol.control.DragBox}
|
||||
* @private
|
||||
*/
|
||||
this.dragBox_ = null;
|
||||
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.ShiftDragZoom, ol.interaction.Drag);
|
||||
|
||||
@@ -37,6 +47,8 @@ goog.inherits(ol.interaction.ShiftDragZoom, ol.interaction.Drag);
|
||||
*/
|
||||
ol.interaction.ShiftDragZoom.prototype.handleDragEnd =
|
||||
function(mapBrowserEvent) {
|
||||
this.dragBox_.setMap(null);
|
||||
this.dragBox = null;
|
||||
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
||||
var map = mapBrowserEvent.map;
|
||||
@@ -55,6 +67,10 @@ ol.interaction.ShiftDragZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (browserEvent.isMouseActionButton() && browserEvent.shiftKey) {
|
||||
this.dragBox_ = new ol.control.DragBox({
|
||||
map: mapBrowserEvent.map,
|
||||
startCoordinate: this.startCoordinate
|
||||
});
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user