add a destroy() function and a clone() function -- they are mostly empty but they are there for people to add on. Also added a check to make sure that a grid has been loaded before trying to re-init tiles after a mergeParams. added extensive tests.

git-svn-id: http://svn.openlayers.org/trunk/openlayers@907 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-07-06 17:07:51 +00:00
parent 9b263461c0
commit a6d4a42058
2 changed files with 158 additions and 49 deletions

View File

@@ -43,7 +43,39 @@ OpenLayers.Layer.WMS.prototype =
}
},
/**
*
*/
destroy: function() {
// for now, nothing special to do here.
OpenLayers.Layer.Grid.prototype.destroy.apply(this, arguments);
},
/**
* @param {Object} obj
*
* @returns An exact clone of this OpenLayers.Layer.WMS
* @type OpenLayers.Layer.WMS
*/
clone: function (obj) {
if (obj == null) {
obj = new OpenLayers.Layer.WMS(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
return obj;
},
/** WMS layer is never a base class.
* @type Boolean
*/
@@ -51,25 +83,6 @@ OpenLayers.Layer.WMS.prototype =
return (this.params.TRANSPARENT != 'true');
},
/**
* @param {String} name
* @param {hash} params
*
* @returns A clone of this OpenLayers.Layer.WMS, with the passed-in
* parameters merged in.
* @type OpenLayers.Layer.WMS
*/
clone: function (name, params) {
var mergedParams = {};
Object.extend(mergedParams, this.params);
Object.extend(mergedParams, params);
var obj = new OpenLayers.Layer.WMS(name, this.url, mergedParams);
if (this.tileSize) {
obj.setTileSize(this.tileSize);
}
return obj;
},
/**
* addTile creates a tile, initializes it, and
* adds it to the layer div.
@@ -103,7 +116,9 @@ OpenLayers.Layer.WMS.prototype =
var newArguments = [upperParams];
OpenLayers.Layer.Grid.prototype.mergeNewParams.apply(this, newArguments);
this._initTiles();
if (this.grid != null) {
this._initTiles();
}
},
/** combine the layer's url with its params and these newParams.