diff --git a/examples/attribution.html b/examples/attribution.html
new file mode 100644
index 0000000000..86d7ac51e7
--- /dev/null
+++ b/examples/attribution.html
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+ OpenLayers Example
+
+
+
diff --git a/lib/OpenLayers.js b/lib/OpenLayers.js
index 59da069e42..7d10370d7d 100644
--- a/lib/OpenLayers.js
+++ b/lib/OpenLayers.js
@@ -125,6 +125,7 @@
"OpenLayers/Handler/MouseWheel.js",
"OpenLayers/Handler/Keyboard.js",
"OpenLayers/Control.js",
+ "OpenLayers/Control/Attribution.js",
"OpenLayers/Control/ZoomBox.js",
"OpenLayers/Control/ZoomToMaxExtent.js",
"OpenLayers/Control/DragPan.js",
diff --git a/lib/OpenLayers/Control/Attribution.js b/lib/OpenLayers/Control/Attribution.js
new file mode 100644
index 0000000000..e079f6b63f
--- /dev/null
+++ b/lib/OpenLayers/Control/Attribution.js
@@ -0,0 +1,78 @@
+/* Copyright (c) 2006-2007 MetaCarta, Inc., published under a modified BSD license.
+ * See http://svn.openlayers.org/trunk/openlayers/repository-license.txt
+ * for the full text of the license. */
+
+/**
+ * @requires OpenLayers/Control.js
+ *
+ * Class: OpenLayers.Control.Attribution
+ * Add attribution from layers to the map display. Uses 'attribution' property
+ * of each layer.
+ */
+OpenLayers.Control.Attribution =
+ OpenLayers.Class(OpenLayers.Control, {
+
+ /**
+ * APIProperty: seperator
+ * {String} String used to seperate layers.
+ */
+ seperator: ", ",
+
+ /**
+ * Constructor: OpenLayers.Control.Attribution
+ *
+ * Parameters:
+ * options - {Object} Options for control.
+ */
+ initialize: function(options) {
+ OpenLayers.Control.prototype.initialize.apply(this, arguments);
+ },
+
+ /**
+ * Method: destroy
+ * Destroy control.
+ */
+ destroy: function() {
+ this.map.events.unregister("removelayer", this, this.updateAttribution);
+ this.map.events.unregister("addlayer", this, this.updateAttribution);
+ this.map.events.unregister("changelayer", this, this.updateAttribution);
+
+ OpenLayers.Control.prototype.destroy.apply(this, arguments);
+ },
+
+ /**
+ * Method: draw
+ * Initialize control.
+ *
+ * Returns:
+ * {DOMElement} A reference to the DIV DOMElement containing the control
+ */
+ draw: function() {
+ OpenLayers.Control.prototype.draw.apply(this, arguments);
+
+ this.map.events.register('changelayer', this, this.updateAttribution);
+ this.map.events.register('addlayer', this, this.updateAttribution);
+ this.map.events.register('removelayer', this, this.updateAttribution);
+ this.updateAttribution();
+
+ return this.div;
+ },
+
+ /**
+ * Method: updateAttribution
+ * Update attribution string.
+ */
+ updateAttribution: function() {
+ var attributions = [];
+ for(var i=0; i < this.map.layers.length; i++) {
+ var layer = this.map.layers[i];
+ if (layer.attribution && layer.getVisibility()) {
+ attributions.push( layer.attribution );
+ }
+ }
+ this.div.innerHTML = attributions.join(this.seperator);
+ },
+
+ /** @final @type String */
+ CLASS_NAME: "OpenLayers.Control.Attribution"
+});
diff --git a/lib/OpenLayers/Layer.js b/lib/OpenLayers/Layer.js
index c5cec481e9..42ec6a38ba 100644
--- a/lib/OpenLayers/Layer.js
+++ b/lib/OpenLayers/Layer.js
@@ -73,6 +73,13 @@ OpenLayers.Layer = OpenLayers.Class({
*/
visibility: true,
+ /**
+ * APIProperty: attribution
+ * {String} Attribution string, displayed when an
+ * has been added to the map.
+ */
+ attribution: null,
+
/**
* Property: inRange
* {Boolean} The current map resolution is within the layer's min/max
diff --git a/tests/Control/test_Attribution.html b/tests/Control/test_Attribution.html
new file mode 100644
index 0000000000..70e914db35
--- /dev/null
+++ b/tests/Control/test_Attribution.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
diff --git a/tests/list-tests.html b/tests/list-tests.html
index 0cf3d878b0..c54630d1d8 100644
--- a/tests/list-tests.html
+++ b/tests/list-tests.html
@@ -62,6 +62,7 @@
Tile/test_Image.html
Tile/test_WFS.html
test_Control.html
+ Control/test_Attribution.html
Control/test_SelectFeature.html
Control/test_DragFeature.html
Control/test_DragPan.html
diff --git a/theme/default/style.css b/theme/default/style.css
index 39e707e58b..d09d5d570c 100644
--- a/theme/default/style.css
+++ b/theme/default/style.css
@@ -10,7 +10,13 @@ div.olMapViewport {
left: 2px;
bottom: 15px;
}
-
+.olControlAttribution {
+ font-size: smaller;
+ right: 3px;
+ bottom: 4.5em;
+ position: absolute;
+ display: block;
+}
.olControlScale {
right: 3px;
bottom: 3em;