Merge pull request #3174 from fredj/view-getState

Use view.getRotation or view.getResolution instead of view.getState
This commit is contained in:
Frédéric Junod
2015-01-26 17:14:38 +01:00
3 changed files with 12 additions and 13 deletions

View File

@@ -68,10 +68,10 @@ ol.interaction.DragRotate.handleDragEvent_ = function(mapBrowserEvent) {
if (goog.isDef(this.lastAngle_)) {
var delta = theta - this.lastAngle_;
var view = map.getView();
var viewState = view.getState();
var rotation = view.getRotation();
map.render();
ol.interaction.Interaction.rotateWithoutConstraints(
map, view, viewState.rotation - delta);
map, view, rotation - delta);
}
this.lastAngle_ = theta;
};
@@ -91,8 +91,8 @@ ol.interaction.DragRotate.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
var viewState = view.getState();
ol.interaction.Interaction.rotate(map, view, viewState.rotation,
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(map, view, rotation,
undefined, ol.DRAGROTATE_ANIMATION_DURATION);
return false;
};

View File

@@ -107,10 +107,10 @@ ol.interaction.PinchRotate.handleDragEvent_ = function(mapBrowserEvent) {
// rotate
if (this.rotating_) {
var view = map.getView();
var viewState = view.getState();
var rotation = view.getRotation();
map.render();
ol.interaction.Interaction.rotateWithoutConstraints(map, view,
viewState.rotation + rotationDelta, this.anchor_);
rotation + rotationDelta, this.anchor_);
}
};
@@ -127,10 +127,9 @@ ol.interaction.PinchRotate.handleUpEvent_ = function(mapBrowserEvent) {
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
if (this.rotating_) {
var viewState = view.getState();
var rotation = view.getRotation();
ol.interaction.Interaction.rotate(
map, view, viewState.rotation, this.anchor_,
ol.ROTATE_ANIMATION_DURATION);
map, view, rotation, this.anchor_, ol.ROTATE_ANIMATION_DURATION);
}
return false;
} else {

View File

@@ -84,7 +84,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
var viewState = view.getState();
var resolution = view.getResolution();
// scale anchor point.
var viewportPosition = goog.style.getClientPosition(map.getViewport());
@@ -97,7 +97,7 @@ ol.interaction.PinchZoom.handleDragEvent_ = function(mapBrowserEvent) {
// scale, bypass the resolution constraint
map.render();
ol.interaction.Interaction.zoomWithoutConstraints(
map, view, viewState.resolution * scaleDelta, this.anchor_);
map, view, resolution * scaleDelta, this.anchor_);
};
@@ -113,12 +113,12 @@ ol.interaction.PinchZoom.handleUpEvent_ = function(mapBrowserEvent) {
var map = mapBrowserEvent.map;
var view = map.getView();
view.setHint(ol.ViewHint.INTERACTING, -1);
var viewState = view.getState();
var resolution = view.getResolution();
// Zoom to final resolution, with an animation, and provide a
// direction not to zoom out/in if user was pinching in/out.
// Direction is > 0 if pinching out, and < 0 if pinching in.
var direction = this.lastScaleDelta_ - 1;
ol.interaction.Interaction.zoom(map, view, viewState.resolution,
ol.interaction.Interaction.zoom(map, view, resolution,
this.anchor_, this.duration_, direction);
return false;
} else {