Change view.rotate params: rotation and optional anchor.

This commit is contained in:
Frederic Junod
2013-02-13 17:03:06 +01:00
parent 83a00c13fa
commit 34975428c4
3 changed files with 53 additions and 42 deletions
+19 -4
View File
@@ -256,11 +256,26 @@ goog.exportProperty(
/**
* @param {ol.Map} map Map.
* @param {number|undefined} rotation Rotation.
* @param {number} delta Delta.
* @param {ol.Coordinate=} opt_anchor Anchor coordinate.
*/
ol.View2D.prototype.rotate = function(map, rotation, delta) {
rotation = this.constraints_.rotation(rotation, delta);
this.setRotation(rotation);
ol.View2D.prototype.rotate = function(map, rotation, opt_anchor) {
rotation = this.constraints_.rotation(rotation, 0);
if (goog.isDefAndNotNull(opt_anchor)) {
var anchor = opt_anchor;
var oldCenter = /** @type {!ol.Coordinate} */ (this.getCenter());
var center = new ol.Coordinate(
oldCenter.x - anchor.x,
oldCenter.y - anchor.y);
center.rotate(rotation - this.getRotation());
center.x += anchor.x;
center.y += anchor.y;
map.withFrozenRendering(function() {
this.setCenter(center);
this.setRotation(rotation);
}, this);
} else {
this.setRotation(rotation);
}
};