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:
euzuro
2006-07-04 16:32:08 +00:00
parent 9149468971
commit f528178e53
2 changed files with 68 additions and 0 deletions

View File

@@ -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