Changing our layers' clone methods so they create a clone of the layer state at the time of clone creation, not at the time the original was created. r=tschaub (closes #2477)

git-svn-id: http://svn.openlayers.org/trunk/openlayers@10045 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
ahocevar
2010-02-10 21:29:37 +00:00
parent 83297678ba
commit 50f26e3313
18 changed files with 41 additions and 21 deletions

View File

@@ -380,8 +380,8 @@ OpenLayers.Layer = OpenLayers.Class({
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer(this.name, this.options);
}
obj = new OpenLayers.Layer(this.name, this.getOptions());
}
// catch any randomly tagged-on properties
OpenLayers.Util.applyDefaults(obj, this);
@@ -393,6 +393,23 @@ OpenLayers.Layer = OpenLayers.Class({
return obj;
},
/**
* Method: getOptions
* Extracts an object from the layer with the properties that were set as
* options, but updates them with the values currently set on the
* instance.
*
* Returns:
* {Object} the <options> of the layer, representing the current state.
*/
getOptions: function() {
var options = {};
for(var o in this.options) {
options[o] = this[o];
}
return options;
},
/**
* APIMethod: setName
* Sets the new layer name for this layer. Can trigger a changelayer event