Add constrainRotation option to ol.View2D
This commit is contained in:
@@ -572,7 +572,17 @@ ol.View2D.createRotationConstraint_ = function(options) {
|
||||
var enableRotation = goog.isDef(options.enableRotation) ?
|
||||
options.enableRotation : true;
|
||||
if (enableRotation) {
|
||||
return ol.RotationConstraint.createSnapToZero();
|
||||
var constrainRotation = options.constrainRotation;
|
||||
if (!goog.isDef(constrainRotation) || constrainRotation === true) {
|
||||
return ol.RotationConstraint.createSnapToZero();
|
||||
} else if (constrainRotation === false) {
|
||||
return ol.RotationConstraint.none;
|
||||
} else if (goog.isNumber(constrainRotation)) {
|
||||
return ol.RotationConstraint.createSnapToN(constrainRotation);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
return ol.RotationConstraint.none;
|
||||
}
|
||||
} else {
|
||||
return ol.RotationConstraint.disable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user