diff --git a/lib/OpenLayers/Control/Attribution.js b/lib/OpenLayers/Control/Attribution.js index fc8bc1fc96..fa686ac327 100644 --- a/lib/OpenLayers/Control/Attribution.js +++ b/lib/OpenLayers/Control/Attribution.js @@ -66,13 +66,15 @@ OpenLayers.Control.Attribution = */ 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.separator); + if (this.map && this.map.layers) { + 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.separator); + } }, /** @final @type String */