Merge pull request #13120 from ahocevar/view-properties

Populate view's object properties
This commit is contained in:
Andreas Hocevar
2021-12-16 22:09:08 +01:00
committed by GitHub
2 changed files with 27 additions and 16 deletions

View File

@@ -416,10 +416,11 @@ class View extends BaseObject {
* @param {ViewOptions} options View options.
*/
applyOptions_(options) {
/**
* @type {Object<string, *>}
*/
const properties = {};
const properties = assign({}, options);
for (const key in ViewProperty) {
delete properties[key];
}
this.setProperties(properties, true);
const resolutionConstraintInfo = createResolutionConstraint(options);
@@ -482,14 +483,6 @@ class View extends BaseObject {
} else if (options.zoom !== undefined) {
this.setZoom(options.zoom);
}
this.setProperties(properties);
/**
* @private
* @type {ViewOptions}
*/
this.options_ = options;
}
/**
@@ -531,7 +524,7 @@ class View extends BaseObject {
* @return {ViewOptions} New options updated with the current view state.
*/
getUpdatedOptions_(newOptions) {
const options = assign({}, this.options_);
const options = this.getProperties();
// preserve resolution (or zoom)
if (options.resolution !== undefined) {
@@ -973,7 +966,7 @@ class View extends BaseObject {
* @return {boolean} Resolution constraint is set
*/
getConstrainResolution() {
return this.options_.constrainResolution;
return this.get('constrainResolution');
}
/**
@@ -1736,6 +1729,7 @@ class View extends BaseObject {
}
if (this.get(ViewProperty.RESOLUTION) !== newResolution) {
this.set(ViewProperty.RESOLUTION, newResolution);
this.set('zoom', this.getZoom(), true);
}
if (
!newCenter ||