add clone() method to Layer class, add test.
git-svn-id: http://svn.openlayers.org/trunk/openlayers@879 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -75,6 +75,30 @@ OpenLayers.Layer.prototype = {
|
||||
}
|
||||
this.map = null;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {String} newName
|
||||
* @param {Hash} newOptions
|
||||
*
|
||||
* @returns A clone of this OpenLayers.Layer
|
||||
* @type OpenLayers.Layer
|
||||
*/
|
||||
clone: function (newName, newOptions) {
|
||||
|
||||
if (newName == null) {
|
||||
newName = this.name;
|
||||
}
|
||||
|
||||
var mergedOptions = null;
|
||||
if ( (this.options != null) || (newOptions != null) ) {
|
||||
// only merge options if there were or will be
|
||||
mergedOptions = Object.extend( {}, this.options);
|
||||
Object.extend(mergedOptions, newOptions);
|
||||
}
|
||||
|
||||
return new OpenLayers.Layer(newName, mergedOptions);
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* @params {OpenLayers.Bounds} bound
|
||||
|
||||
Reference in New Issue
Block a user