diff --git a/lib/OpenLayers/Control/Attribution.js b/lib/OpenLayers/Control/Attribution.js index 621f6be77d..25aa069280 100644 --- a/lib/OpenLayers/Control/Attribution.js +++ b/lib/OpenLayers/Control/Attribution.js @@ -24,6 +24,14 @@ OpenLayers.Control.Attribution = */ separator: ", ", + /** + * APIProperty: template + * {String} Template for the attribution. This has to include the substring + * "${layers}", which will be replaced by the layer specific + * attributions, separated by . The default is "${layers}". + */ + template: "${layers}", + /** * Constructor: OpenLayers.Control.Attribution * @@ -86,7 +94,9 @@ OpenLayers.Control.Attribution = } } } - this.div.innerHTML = attributions.join(this.separator); + this.div.innerHTML = OpenLayers.String.format(this.template, { + layers: attributions.join(this.separator) + }); } }, diff --git a/tests/Control/Attribution.html b/tests/Control/Attribution.html index c1c1ef228b..04b85cfdb3 100644 --- a/tests/Control/Attribution.html +++ b/tests/Control/Attribution.html @@ -30,8 +30,9 @@ 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.separator = '|'; + control.template = "Map Copyright (c) 2012 by Foo Bar; ${layers}"; 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."); + t.eq(control.div.innerHTML, 'Map Copyright (c) 2012 by Foo Bar; My layer!|My layer 2!|My layer 3!', "Attribution correct with three layers and diff seperator."); }