Change view.rotate params: rotation and optional anchor.
This commit is contained in:
+19
-4
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user