diff --git a/lib/OpenLayers/Layer/ArcIMS.js b/lib/OpenLayers/Layer/ArcIMS.js index 834fdcd51b..67d438e67f 100644 --- a/lib/OpenLayers/Layer/ArcIMS.js +++ b/lib/OpenLayers/Layer/ArcIMS.js @@ -420,6 +420,29 @@ OpenLayers.Layer.ArcIMS = OpenLayers.Class(OpenLayers.Layer.Grid, { } }); }, + + /** + * Method: clone + * Create a clone of this layer + * + * Returns: + * {} An exact clone of this layer + */ + clone: function (obj) { + + if (obj == null) { + obj = new OpenLayers.Layer.ArcIMS(this.name, + this.url, + this.getOptions()); + } + + //get all additions from superclasses + obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]); + + // copy/set any non-init, non-simple values here + + return obj; + }, /** * Method: addTile diff --git a/tests/Layer/ArcIMS.html b/tests/Layer/ArcIMS.html index 051c5c7d5c..48cf30909b 100644 --- a/tests/Layer/ArcIMS.html +++ b/tests/Layer/ArcIMS.html @@ -83,7 +83,41 @@ t.eq( typeof layer.options.layers[0].query.where, "string", "where query is a string" ); t.eq( layer.options.layers[0].query.where, querydef.where, "where query matches" ); } + function test_Layer_ArcIMS_clone (t) { + t.plan(5); + + var url = imsUrl; + var options = { + serviceName: serviceName, + async: false, + displayOutsideMaxExtent: true + }; + var map = new OpenLayers.Map('map', {controls: []}); + var layer = new OpenLayers.Layer.ArcIMS(name, url, options); + map.addLayer(layer); + + layer.grid = [ [6, 7], + [8, 9]]; + + var clone = layer.clone(); + + t.ok( clone.grid != layer.grid, "clone does not copy grid"); + + t.ok( clone.tileSize.equals(layer.tileSize), "tileSize correctly cloned"); + + t.eq( clone.params.serviceName, layer.params.serviceName, "serviceName copied correctly"); + + t.eq( clone.async, layer.async, "async copied correctly"); + + t.eq( clone.url, layer.url, "url copied correctly"); + + layer.grid = null; + map.destroy(); + } - \ No newline at end of file + +
+ +