From 28ba3309c175de950ff5922b7ebedb3ed288618d Mon Sep 17 00:00:00 2001 From: crschmidt Date: Thu, 19 Apr 2007 20:00:15 +0000 Subject: [PATCH] Fix ka-Map's clone method, to fix bug with Overview Map reported by Stephen Woodbridge. (Thx Stephen.) git-svn-id: http://svn.openlayers.org/trunk/openlayers@3087 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- lib/OpenLayers/Layer/KaMap.js | 30 ++++++++++++++++++++++++++++++ tests/Layer/test_KaMap.html | 4 +++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/lib/OpenLayers/Layer/KaMap.js b/lib/OpenLayers/Layer/KaMap.js index 7cbd7d8898..a1e736e124 100644 --- a/lib/OpenLayers/Layer/KaMap.js +++ b/lib/OpenLayers/Layer/KaMap.js @@ -145,6 +145,36 @@ OpenLayers.Layer.KaMap.prototype = this.spiralTileLoad(); }, + + /** + * @param {Object} obj + * + * @returns An exact clone of this OpenLayers.Layer.Grid + * @type OpenLayers.Layer.Grid + */ + clone: function (obj) { + + if (obj == null) { + obj = new OpenLayers.Layer.KaMap(this.name, + this.url, + this.params, + this.options); + } + + //get all additions from superclasses + obj = OpenLayers.Layer.Grid.prototype.clone.apply(this, [obj]); + + // copy/set any non-init, non-simple values here + if (this.tileSize != null) { + obj.tileSize = this.tileSize.clone(); + } + + // we do not want to copy reference to grid, so we make a new array + obj.grid = new Array(); + + return obj; + }, + /** @final @type String */ CLASS_NAME: "OpenLayers.Layer.KaMap" diff --git a/tests/Layer/test_KaMap.html b/tests/Layer/test_KaMap.html index 579d761b0f..de11585e9f 100644 --- a/tests/Layer/test_KaMap.html +++ b/tests/Layer/test_KaMap.html @@ -147,7 +147,7 @@ */ function test_10_Layer_KaMap_clone(t) { - t.plan(4); + t.plan(5); var options = {tileSize: new OpenLayers.Size(500,50)}; var map = new OpenLayers.Map('map', options); @@ -168,6 +168,8 @@ t.eq( clone.tileSize.w, 500, "changing layer.tileSize does not change clone.tileSize -- a fresh copy was made, not just copied reference"); t.eq( clone.alpha, layer.alpha, "alpha copied correctly"); + + t.eq( clone.CLASS_NAME, "OpenLayers.Layer.KaMap", "Clone is a ka-map layer"); layer.grid = null; }