Merge pull request #5809 from fredj/reuse_layerState
Reuse ol.LayerState object
This commit is contained in:
@@ -54,6 +54,16 @@ ol.layer.Base = function(options) {
|
|||||||
options.minResolution !== undefined ? options.minResolution : 0;
|
options.minResolution !== undefined ? options.minResolution : 0;
|
||||||
|
|
||||||
this.setProperties(properties);
|
this.setProperties(properties);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {ol.LayerState}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.state_ = /** @type {ol.LayerState} */ ({
|
||||||
|
layer: /** @type {ol.layer.Layer} */ (this),
|
||||||
|
managed: true
|
||||||
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
ol.inherits(ol.layer.Base, ol.Object);
|
ol.inherits(ol.layer.Base, ol.Object);
|
||||||
|
|
||||||
@@ -62,24 +72,15 @@ ol.inherits(ol.layer.Base, ol.Object);
|
|||||||
* @return {ol.LayerState} Layer state.
|
* @return {ol.LayerState} Layer state.
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getLayerState = function() {
|
ol.layer.Base.prototype.getLayerState = function() {
|
||||||
var opacity = this.getOpacity();
|
this.state_.opacity = ol.math.clamp(this.getOpacity(), 0, 1);
|
||||||
var sourceState = this.getSourceState();
|
this.state_.sourceState = this.getSourceState();
|
||||||
var visible = this.getVisible();
|
this.state_.visible = this.getVisible();
|
||||||
var extent = this.getExtent();
|
this.state_.extent = this.getExtent();
|
||||||
var zIndex = this.getZIndex();
|
this.state_.zIndex = this.getZIndex();
|
||||||
var maxResolution = this.getMaxResolution();
|
this.state_.maxResolution = this.getMaxResolution();
|
||||||
var minResolution = this.getMinResolution();
|
this.state_.minResolution = Math.max(this.getMinResolution(), 0);
|
||||||
return {
|
|
||||||
layer: /** @type {ol.layer.Layer} */ (this),
|
return this.state_;
|
||||||
opacity: ol.math.clamp(opacity, 0, 1),
|
|
||||||
sourceState: sourceState,
|
|
||||||
visible: visible,
|
|
||||||
managed: true,
|
|
||||||
extent: extent,
|
|
||||||
zIndex: zIndex,
|
|
||||||
maxResolution: maxResolution,
|
|
||||||
minResolution: Math.max(minResolution, 0)
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user