Do not draw a rotated box, in dragbox/dragzoom
Use pixels to draw a straight box, perserving rotation while zooming
This commit is contained in:
@@ -92,6 +92,12 @@ ol.interaction.DragBox = function(opt_options) {
|
||||
*/
|
||||
this.box_ = new ol.render.Box(style);
|
||||
|
||||
/**
|
||||
* @type {ol.Pixel}
|
||||
* @private
|
||||
*/
|
||||
this.startPixel_ = null;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.events.ConditionType}
|
||||
@@ -107,8 +113,7 @@ goog.inherits(ol.interaction.DragBox, ol.interaction.Drag);
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.DragBox.prototype.handleDrag = function(mapBrowserEvent) {
|
||||
this.box_.setCoordinates(
|
||||
this.startCoordinate, mapBrowserEvent.getCoordinate());
|
||||
this.box_.setPixels(this.startPixel_, mapBrowserEvent.getPixel());
|
||||
};
|
||||
|
||||
|
||||
@@ -150,8 +155,9 @@ ol.interaction.DragBox.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
if (browserEvent.isMouseActionButton() && this.condition_(mapBrowserEvent)) {
|
||||
this.box_.setCoordinates(this.startCoordinate, this.startCoordinate);
|
||||
this.startPixel_ = mapBrowserEvent.getPixel();
|
||||
this.box_.setMap(mapBrowserEvent.map);
|
||||
this.box_.setPixels(this.startPixel_, this.startPixel_);
|
||||
this.dispatchEvent(new ol.DragBoxEvent(ol.DragBoxEventType.BOXSTART,
|
||||
mapBrowserEvent.getCoordinate()));
|
||||
return true;
|
||||
|
||||
@@ -52,7 +52,5 @@ ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
||||
var view = this.getMap().getView().getView2D();
|
||||
|
||||
view.fitExtent(this.getGeometry().getExtent(), this.getMap().getSize());
|
||||
// FIXME we should preserve rotation
|
||||
view.setRotation(0);
|
||||
}, this));
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user