1 /* Copyright (c) 2006-2008 MetaCarta, Inc., published under the Clear BSD
2 * license. See http://svn.openlayers.org/trunk/openlayers/license.txt for the
3 * full text of the license. */
6 * @requires OpenLayers/Control.js
10 * Class: OpenLayers.Control.Attribution
11 * The attribution control adds attribution from layers to the map display.
12 * It uses 'attribution' property of each layer.
15 * - <OpenLayers.Control>
17 OpenLayers.Control.Attribution =
18 OpenLayers.Class(OpenLayers.Control, {
21 * APIProperty: seperator
22 * {String} String used to seperate layers.
27 * Constructor: OpenLayers.Control.Attribution
30 * options - {Object} Options for control.
32 initialize: function(options) {
33 OpenLayers.Control.prototype.initialize.apply(this, arguments);
42 "removelayer": this.updateAttribution,
43 "addlayer": this.updateAttribution,
44 "changelayer": this.updateAttribution,
45 "changebaselayer": this.updateAttribution,
49 OpenLayers.Control.prototype.destroy.apply(this, arguments);
57 * {DOMElement} A reference to the DIV DOMElement containing the control
60 OpenLayers.Control.prototype.draw.apply(this, arguments);
63 'changebaselayer': this.updateAttribution,
64 'changelayer': this.updateAttribution,
65 'addlayer': this.updateAttribution,
66 'removelayer': this.updateAttribution,
69 this.updateAttribution();
75 * Method: updateAttribution
76 * Update attribution string.
78 updateAttribution: function() {
79 var attributions = [];
80 if (this.map && this.map.layers) {
81 for(var i=0, len=this.map.layers.length; i<len; i++) {
82 var layer = this.map.layers[i];
83 if (layer.attribution && layer.getVisibility()) {
84 attributions.push( layer.attribution );
87 this.div.innerHTML = attributions.join(this.separator);
91 CLASS_NAME: "OpenLayers.Control.Attribution"