[OpenLayers-Commits] r4237 - in trunk/openlayers: lib/OpenLayers/Control tests/Control
commits at openlayers.org
commits at openlayers.org
Wed Sep 12 09:40:29 EDT 2007
Author: crschmidt
Date: 2007-09-12 09:40:28 -0400 (Wed, 12 Sep 2007)
New Revision: 4237
Modified:
trunk/openlayers/lib/OpenLayers/Control/Attribution.js
trunk/openlayers/tests/Control/test_Attribution.html
Log:
FredJ reviewed my work here and said it solved the problem that he reopened
103 for (specifically, that baselayer changes always resulted in a null
attribution string), and fixes spelling. This commit makes the attribution
control work and stuff. (Closes #103)
Modified: trunk/openlayers/lib/OpenLayers/Control/Attribution.js
===================================================================
--- trunk/openlayers/lib/OpenLayers/Control/Attribution.js 2007-09-12 13:40:11 UTC (rev 4236)
+++ trunk/openlayers/lib/OpenLayers/Control/Attribution.js 2007-09-12 13:40:28 UTC (rev 4237)
@@ -16,7 +16,7 @@
* APIProperty: seperator
* {String} String used to seperate layers.
*/
- seperator: ", ",
+ separator: ", ",
/**
* Constructor: OpenLayers.Control.Attribution
@@ -36,6 +36,7 @@
this.map.events.unregister("removelayer", this, this.updateAttribution);
this.map.events.unregister("addlayer", this, this.updateAttribution);
this.map.events.unregister("changelayer", this, this.updateAttribution);
+ this.map.events.unregister("changebaselayer", this, this.updateAttribution);
OpenLayers.Control.prototype.destroy.apply(this, arguments);
},
@@ -50,6 +51,7 @@
draw: function() {
OpenLayers.Control.prototype.draw.apply(this, arguments);
+ this.map.events.register('changebaselayer', this, this.updateAttribution);
this.map.events.register('changelayer', this, this.updateAttribution);
this.map.events.register('addlayer', this, this.updateAttribution);
this.map.events.register('removelayer', this, this.updateAttribution);
@@ -70,7 +72,7 @@
attributions.push( layer.attribution );
}
}
- this.div.innerHTML = attributions.join(this.seperator);
+ this.div.innerHTML = attributions.join(this.separator);
},
/** @final @type String */
Modified: trunk/openlayers/tests/Control/test_Attribution.html
===================================================================
--- trunk/openlayers/tests/Control/test_Attribution.html 2007-09-12 13:40:11 UTC (rev 4236)
+++ trunk/openlayers/tests/Control/test_Attribution.html 2007-09-12 13:40:28 UTC (rev 4237)
@@ -10,6 +10,16 @@
t.ok( control instanceof OpenLayers.Control.Attribution, "new OpenLayers.Control returns object" );
t.eq( control.displayClass, "olControlAttribution", "displayClass is correct" );
}
+ function test_Control_Attribution_setBaseLayer (t) {
+ t.plan(1);
+ map = new OpenLayers.Map("map");
+ map.addControl(control);
+ map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer!', isBaseLayer: true}));
+ map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 2!', isBaseLayer: true}));
+ map.setBaseLayer(map.layers[1]);
+ t.eq(control.div.innerHTML, 'My layer 2!', "Attribution correct with changed base layer");
+
+ }
function test_Control_Attribution_draw (t) {
t.plan(3);
control = new OpenLayers.Control.Attribution();
@@ -19,9 +29,11 @@
t.eq(control.div.innerHTML, 'My layer!', "Attribution correct with one layer.");
map.addLayer(new OpenLayers.Layer("name", {'attribution':'My layer 2!'}));
t.eq(control.div.innerHTML, 'My layer!, My layer 2!', "Attribution correct with two layers.");
- control.seperator = '|';
+ control.separator = '|';
map.addLayer(new OpenLayers.Layer("name",{'attribution':'My layer 3!'}));
t.eq(control.div.innerHTML, 'My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator.");
+
+
}
// -->
</script>
More information about the Commits
mailing list