Set default View2D rotation in constructor and getView2DState instead of in getRotation
This commit is contained in:
+6
-7
@@ -89,7 +89,8 @@ ol.View2D = function(opt_options) {
|
|||||||
values[ol.View2DProperty.RESOLUTION] = resolutionConstraint(
|
values[ol.View2DProperty.RESOLUTION] = resolutionConstraint(
|
||||||
this.maxResolution_, options.zoom);
|
this.maxResolution_, options.zoom);
|
||||||
}
|
}
|
||||||
values[ol.View2DProperty.ROTATION] = options.rotation;
|
values[ol.View2DProperty.ROTATION] =
|
||||||
|
goog.isDef(options.rotation) ? options.rotation : 0;
|
||||||
this.setValues(values);
|
this.setValues(values);
|
||||||
};
|
};
|
||||||
goog.inherits(ol.View2D, ol.View);
|
goog.inherits(ol.View2D, ol.View);
|
||||||
@@ -254,12 +255,10 @@ ol.View2D.prototype.getResolutionForValueFunction = function(opt_power) {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current rotation of this view.
|
* @inheritDoc
|
||||||
* @return {number} Map rotation.
|
|
||||||
*/
|
*/
|
||||||
ol.View2D.prototype.getRotation = function() {
|
ol.View2D.prototype.getRotation = function() {
|
||||||
return /** @type {number|undefined} */ (
|
return /** @type {number|undefined} */ (this.get(ol.View2DProperty.ROTATION));
|
||||||
this.get(ol.View2DProperty.ROTATION)) || 0;
|
|
||||||
};
|
};
|
||||||
goog.exportProperty(
|
goog.exportProperty(
|
||||||
ol.View2D.prototype,
|
ol.View2D.prototype,
|
||||||
@@ -308,12 +307,12 @@ ol.View2D.prototype.getView2DState = function() {
|
|||||||
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
var center = /** @type {ol.Coordinate} */ (this.getCenter());
|
||||||
var projection = /** @type {ol.Projection} */ (this.getProjection());
|
var projection = /** @type {ol.Projection} */ (this.getProjection());
|
||||||
var resolution = /** @type {number} */ (this.getResolution());
|
var resolution = /** @type {number} */ (this.getResolution());
|
||||||
var rotation = /** @type {number} */ (this.getRotation());
|
var rotation = this.getRotation();
|
||||||
return {
|
return {
|
||||||
center: center.slice(),
|
center: center.slice(),
|
||||||
projection: projection,
|
projection: projection,
|
||||||
resolution: resolution,
|
resolution: resolution,
|
||||||
rotation: rotation
|
rotation: goog.isDef(rotation) ? rotation : 0
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user