Removing option for temporary layer

Instead, adding setter and getter for a private temp_ property,
as suggested by @elemoine.
This commit is contained in:
ahocevar
2013-08-21 09:52:52 +02:00
parent 3a50a754aa
commit 56c228d009
4 changed files with 24 additions and 7 deletions

View File

@@ -367,7 +367,6 @@
* @property {number|undefined} opacity Opacity. 0-1. Default is 1.
* @property {ol.source.Source} source Source for this layer.
* @property {ol.style.Style|undefined} style Style.
* @property {boolean|undefined} temp True for temporary layers. For internal use only.
* @property {boolean|undefined} visible Visibility. Default is true (visible).
*/

View File

@@ -94,11 +94,12 @@ ol.control.Select.prototype.createSelectionLayers_ = function() {
this.selectionLayers = [];
for (var i = 0, ii = this.layers_.length; i < ii; ++i) {
this.featureMap_.push({});
this.selectionLayers.push(new ol.layer.Vector({
var selectionLayer = new ol.layer.Vector({
source: new ol.source.Vector({parser: null}),
style: this.layers_[i].getStyle(),
temp: true
}));
style: this.layers_[i].getStyle()
});
selectionLayer.setTemporary(true);
this.selectionLayers.push(selectionLayer);
}
};

View File

@@ -303,8 +303,9 @@ ol.layer.Vector = function(options) {
/**
* True if this is a temporary layer.
* @type {boolean}
* @private
*/
this.temp = goog.isDef(options.temp) ? options.temp : false;
this.temp_ = false;
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -343,6 +344,14 @@ ol.layer.Vector.prototype.clear = function() {
};
/**
* @return {boolean} Whether this layer is temporary.
*/
ol.layer.Vector.prototype.getTemporary = function() {
return this.temp_;
};
/**
* @return {ol.source.Vector} Source.
*/
@@ -604,6 +613,14 @@ ol.layer.Vector.prototype.setRenderIntent = function(renderIntent, features) {
};
/**
* @param {boolean} temp Whether this layer is temporary.
*/
ol.layer.Vector.prototype.setTemporary = function(temp) {
this.temp_ = temp;
};
/**
* @param {Array.<ol.Feature>} features Features.
* @return {string} Feature info.