Allow options to be reapplied
This commit is contained in:
+28
-9
@@ -16,6 +16,7 @@ goog.require('ol.extent');
|
|||||||
goog.require('ol.geom.GeometryType');
|
goog.require('ol.geom.GeometryType');
|
||||||
goog.require('ol.geom.Polygon');
|
goog.require('ol.geom.Polygon');
|
||||||
goog.require('ol.geom.SimpleGeometry');
|
goog.require('ol.geom.SimpleGeometry');
|
||||||
|
goog.require('ol.obj');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.proj.Units');
|
goog.require('ol.proj.Units');
|
||||||
|
|
||||||
@@ -79,7 +80,8 @@ goog.require('ol.proj.Units');
|
|||||||
*/
|
*/
|
||||||
ol.View = function(opt_options) {
|
ol.View = function(opt_options) {
|
||||||
ol.Object.call(this);
|
ol.Object.call(this);
|
||||||
var options = opt_options || {};
|
|
||||||
|
var options = ol.obj.assign({}, opt_options);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -101,13 +103,6 @@ ol.View = function(opt_options) {
|
|||||||
|
|
||||||
this.updateAnimations_ = this.updateAnimations_.bind(this);
|
this.updateAnimations_ = this.updateAnimations_.bind(this);
|
||||||
|
|
||||||
/**
|
|
||||||
* @type {Object.<string, *>}
|
|
||||||
*/
|
|
||||||
var properties = {};
|
|
||||||
properties[ol.ViewProperty.CENTER] = options.center !== undefined ?
|
|
||||||
options.center : null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @const
|
* @const
|
||||||
@@ -115,6 +110,24 @@ ol.View = function(opt_options) {
|
|||||||
*/
|
*/
|
||||||
this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857');
|
this.projection_ = ol.proj.createProjection(options.projection, 'EPSG:3857');
|
||||||
|
|
||||||
|
this.applyOptions_(options);
|
||||||
|
};
|
||||||
|
ol.inherits(ol.View, ol.Object);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the view with the given options.
|
||||||
|
* @param {olx.ViewOptions} options View options.
|
||||||
|
*/
|
||||||
|
ol.View.prototype.applyOptions_ = function(options) {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object.<string, *>}
|
||||||
|
*/
|
||||||
|
var properties = {};
|
||||||
|
properties[ol.ViewProperty.CENTER] = options.center !== undefined ?
|
||||||
|
options.center : null;
|
||||||
|
|
||||||
var resolutionConstraintInfo = ol.View.createResolutionConstraint_(
|
var resolutionConstraintInfo = ol.View.createResolutionConstraint_(
|
||||||
options);
|
options);
|
||||||
|
|
||||||
@@ -168,8 +181,14 @@ ol.View = function(opt_options) {
|
|||||||
properties[ol.ViewProperty.ROTATION] =
|
properties[ol.ViewProperty.ROTATION] =
|
||||||
options.rotation !== undefined ? options.rotation : 0;
|
options.rotation !== undefined ? options.rotation : 0;
|
||||||
this.setProperties(properties);
|
this.setProperties(properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {olx.ViewOptions}
|
||||||
|
*/
|
||||||
|
this.options_ = options;
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.View, ol.Object);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user