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:
@@ -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
|
||||
|
||||
@@ -113,7 +113,7 @@ OpenLayers.Layer.ArcGIS93Rest = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.ArcGIS93Rest(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -130,7 +130,7 @@ OpenLayers.Layer.Grid = OpenLayers.Class(OpenLayers.Layer.HTTPRequest, {
|
||||
obj = new OpenLayers.Layer.Grid(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -89,7 +89,7 @@ OpenLayers.Layer.HTTPRequest = OpenLayers.Class(OpenLayers.Layer, {
|
||||
obj = new OpenLayers.Layer.HTTPRequest(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -108,7 +108,7 @@ OpenLayers.Layer.Image = OpenLayers.Class(OpenLayers.Layer, {
|
||||
this.url,
|
||||
this.extent,
|
||||
this.size,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -162,7 +162,7 @@ OpenLayers.Layer.KaMap = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.KaMap(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -224,7 +224,7 @@ OpenLayers.Layer.MapGuide = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.MapGuide(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
//get all additions from superclasses
|
||||
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
|
||||
|
||||
@@ -66,7 +66,7 @@ OpenLayers.Layer.MapServer = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.MapServer(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
//get all additions from superclasses
|
||||
obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]);
|
||||
|
||||
@@ -56,14 +56,14 @@ OpenLayers.Layer.MapServer.Untiled = OpenLayers.Class(OpenLayers.Layer.MapServer
|
||||
obj = new OpenLayers.Layer.MapServer.Untiled(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
obj = OpenLayers.Layer.MapServer.prototype.clone.apply(this, [obj]);
|
||||
|
||||
// copy/set any non-init, non-simple values here
|
||||
|
||||
|
||||
return obj;
|
||||
},
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ OpenLayers.Layer.TMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.TMS(this.name,
|
||||
this.url,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -78,7 +78,7 @@ OpenLayers.Layer.TileCache = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.TileCache(this.name,
|
||||
this.url,
|
||||
this.layername,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -314,7 +314,7 @@ OpenLayers.Layer.Vector = OpenLayers.Class(OpenLayers.Layer, {
|
||||
clone: function (obj) {
|
||||
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.Vector(this.name, this.options);
|
||||
obj = new OpenLayers.Layer.Vector(this.name, this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -442,7 +442,7 @@ OpenLayers.Layer.WFS = OpenLayers.Class(
|
||||
obj = new OpenLayers.Layer.WFS(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -145,7 +145,7 @@ OpenLayers.Layer.WMS = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
obj = new OpenLayers.Layer.WMS(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -56,7 +56,7 @@ OpenLayers.Layer.WMS.Untiled = OpenLayers.Class(OpenLayers.Layer.WMS, {
|
||||
obj = new OpenLayers.Layer.WMS.Untiled(this.name,
|
||||
this.url,
|
||||
this.params,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
@@ -72,7 +72,7 @@ OpenLayers.Layer.XYZ = OpenLayers.Class(OpenLayers.Layer.Grid, {
|
||||
if (obj == null) {
|
||||
obj = new OpenLayers.Layer.XYZ(this.name,
|
||||
this.url,
|
||||
this.options);
|
||||
this.getOptions());
|
||||
}
|
||||
|
||||
//get all additions from superclasses
|
||||
|
||||
Reference in New Issue
Block a user