give layer a unique id. udpate tests
git-svn-id: http://svn.openlayers.org/trunk/openlayers@977 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
OpenLayers.Layer = Class.create();
|
||||
OpenLayers.Layer.prototype = {
|
||||
|
||||
/** @type String */
|
||||
id: null,
|
||||
|
||||
/** @type String */
|
||||
name: null,
|
||||
|
||||
@@ -57,6 +60,10 @@ OpenLayers.Layer.prototype = {
|
||||
Object.extend(this, this.options);
|
||||
|
||||
this.name = name;
|
||||
|
||||
//generate unique id based on name
|
||||
this.id = OpenLayers.Util.createUniqueID(name);
|
||||
|
||||
if (this.div == null) {
|
||||
this.div = OpenLayers.Util.createDiv();
|
||||
this.div.style.width = "100%";
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
var layer;
|
||||
|
||||
function test_01_Layer_constructor (t) {
|
||||
t.plan( 12 );
|
||||
t.plan( 14 );
|
||||
|
||||
var options = { chicken: 151, foo: "bar", projection: "none" };
|
||||
var layer = new OpenLayers.Layer('Test Layer', options);
|
||||
@@ -14,6 +14,8 @@
|
||||
t.eq( layer.CLASS_NAME, "OpenLayers.Layer", "CLASS_NAME variable set correctly");
|
||||
|
||||
t.eq( layer.name, "Test Layer", "layer.name is correct" );
|
||||
t.ok( layer.id != null, "Layer is given an id");
|
||||
t.ok( layer.id.startsWith(layer.name), "layer id starts with layer name");
|
||||
t.ok( layer.projection, "none", "default layer projection correctly set");
|
||||
t.ok( ((layer.chicken == 151) && (layer.foo == "bar")), "layer.options correctly set to Layer Object" );
|
||||
t.ok( ((layer.options["chicken"] == 151) && (layer.options["foo"] == "bar")), "layer.options correctly backed up" );
|
||||
|
||||
Reference in New Issue
Block a user