From 3eebed45808fcff0a9942072d347a589e9017674 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Fri, 28 Sep 2012 17:24:08 +0200 Subject: [PATCH] Add drag box in shift drag zoom control --- src/ol/interaction/shiftdragzoom.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ol/interaction/shiftdragzoom.js b/src/ol/interaction/shiftdragzoom.js index 5712353513..2a83171036 100644 --- a/src/ol/interaction/shiftdragzoom.js +++ b/src/ol/interaction/shiftdragzoom.js @@ -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;