Give each source file a unique name
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
goog.provide('ol.interaction.DragRotateAndZoom');
|
||||
|
||||
goog.require('goog.math.Vec2');
|
||||
goog.require('ol.MapBrowserEvent');
|
||||
goog.require('ol.interaction.ConditionType');
|
||||
goog.require('ol.interaction.Drag');
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.interaction.Drag}
|
||||
* @param {ol.interaction.ConditionType} condition Condition.
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom = function(condition) {
|
||||
|
||||
goog.base(this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.interaction.ConditionType}
|
||||
*/
|
||||
this.condition_ = condition;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.startRatio_ = 0;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.startRotation_ = 0;
|
||||
|
||||
};
|
||||
goog.inherits(ol.interaction.DragRotateAndZoom, ol.interaction.Drag);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDrag =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
var size = map.getSize();
|
||||
var delta = new goog.math.Vec2(
|
||||
browserEvent.offsetX - size.width / 2,
|
||||
size.height / 2 - browserEvent.offsetY);
|
||||
var theta = Math.atan2(delta.y, delta.x);
|
||||
// FIXME this should use map.withFrozenRendering but an assertion fails :-(
|
||||
map.rotate(this.startRotation_, -theta);
|
||||
var resolution = this.startRatio_ * delta.magnitude();
|
||||
map.zoomToResolution(resolution);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.interaction.DragRotateAndZoom.prototype.handleDragStart =
|
||||
function(mapBrowserEvent) {
|
||||
var browserEvent = mapBrowserEvent.browserEvent;
|
||||
var map = mapBrowserEvent.map;
|
||||
if (map.canRotate() && this.condition_(browserEvent)) {
|
||||
var resolution = map.getResolution();
|
||||
var size = map.getSize();
|
||||
var delta = new goog.math.Vec2(
|
||||
browserEvent.offsetX - size.width / 2,
|
||||
size.height / 2 - browserEvent.offsetY);
|
||||
var theta = Math.atan2(delta.y, delta.x);
|
||||
this.startRotation_ = (map.getRotation() || 0) + theta;
|
||||
this.startRatio_ = resolution / delta.magnitude();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user