Use ol.render.DragBox in ol.interaction.DragZoom
This commit is contained in:
@@ -6,11 +6,11 @@ goog.provide('ol.interaction.DragZoom');
|
|||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.Size');
|
goog.require('ol.Size');
|
||||||
goog.require('ol.View2D');
|
goog.require('ol.View2D');
|
||||||
goog.require('ol.control.DragBox');
|
|
||||||
goog.require('ol.events.ConditionType');
|
goog.require('ol.events.ConditionType');
|
||||||
goog.require('ol.events.condition');
|
goog.require('ol.events.condition');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
goog.require('ol.interaction.Drag');
|
goog.require('ol.interaction.Drag');
|
||||||
|
goog.require('ol.render.DragBox');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,23 +51,30 @@ ol.interaction.DragZoom = function(opt_options) {
|
|||||||
options.condition : ol.events.condition.shiftKeyOnly;
|
options.condition : ol.events.condition.shiftKeyOnly;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {ol.control.DragBox}
|
* @type {ol.render.DragBox}
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
this.dragBox_ = null;
|
this.dragBox_ = new ol.render.DragBox();
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.interaction.DragZoom, ol.interaction.Drag);
|
goog.inherits(ol.interaction.DragZoom, ol.interaction.Drag);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @inheritDoc
|
||||||
|
*/
|
||||||
|
ol.interaction.DragZoom.prototype.handleDrag = function(mapBrowserEvent) {
|
||||||
|
this.dragBox_.setCoordinates(
|
||||||
|
this.startCoordinate, mapBrowserEvent.getCoordinate());
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @inheritDoc
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
ol.interaction.DragZoom.prototype.handleDragEnd =
|
ol.interaction.DragZoom.prototype.handleDragEnd =
|
||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
this.dragBox_.setMap(null);
|
this.dragBox_.setMap(null);
|
||||||
this.dragBox_ = null;
|
|
||||||
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
if (this.deltaX * this.deltaX + this.deltaY * this.deltaY >=
|
||||||
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
ol.SHIFT_DRAG_ZOOM_HYSTERESIS_PIXELS_SQUARED) {
|
||||||
var map = mapBrowserEvent.map;
|
var map = mapBrowserEvent.map;
|
||||||
@@ -93,9 +100,7 @@ ol.interaction.DragZoom.prototype.handleDragStart =
|
|||||||
function(mapBrowserEvent) {
|
function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.browserEvent;
|
var browserEvent = mapBrowserEvent.browserEvent;
|
||||||
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
||||||
this.dragBox_ = new ol.control.DragBox({
|
this.dragBox_.setCoordinates(this.startCoordinate, this.startCoordinate);
|
||||||
startCoordinate: this.startCoordinate
|
|
||||||
});
|
|
||||||
this.dragBox_.setMap(mapBrowserEvent.map);
|
this.dragBox_.setMap(mapBrowserEvent.map);
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user