code: function (obj) {
          
          if (obj == null) {
              obj = new OpenLayers.Layer.Vector(this.name, this.getOptions());
          }
  
          //get all additions from superclasses
          obj = OpenLayers.Layer.prototype.clone.apply(this, [obj]);
  
          // copy/set any non-init, non-simple values here
          var features = this.features;
          var len = features.length;
          var clonedFeatures = new Array(len);
          for(var i=0; i<len; ++i) {
              clonedFeatures[i] = features[i].clone();
          }
          obj.features = clonedFeatures;
  
          return obj;
      }
docs: Method: clone
  Create a clone of this layer.
  
  Note: Features of the layer are also cloned.
  
  Returns:
  {<OpenLayers.Layer.Vector>} An exact clone of this layer