From e027f9771e34b4138ccc541ce3ba14e6316a8e40 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Wed, 6 Mar 2013 17:53:32 +0100 Subject: [PATCH] Use a single, shared attribution for Stamen sources This ensures that the attribution only appears once, even if multiple Stamen layers are used in the same map. --- src/ol/source/stamensource.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/ol/source/stamensource.js b/src/ol/source/stamensource.js index 6ea87b6ab4..a29ec962da 100644 --- a/src/ol/source/stamensource.js +++ b/src/ol/source/stamensource.js @@ -74,6 +74,16 @@ ol.source.StamenProviderConfig = { }; +/** + * @const {Array.} + */ +ol.source.STAMEN_ATTRIBUTIONS = [new ol.Attribution( + 'Map tiles by Stamen Design, under ' + + 'CC BY 3.0. ' + + 'Data by OpenStreetMap, under ' + + 'CC BY SA.')]; + + /** * @constructor @@ -82,14 +92,6 @@ ol.source.StamenProviderConfig = { */ ol.source.Stamen = function(options) { - var attribution = new ol.Attribution( - 'Map tiles by Stamen Design, ' + - 'under ' + - 'CC BY 3.0. ' + - 'Data by OpenStreetMap, ' + - 'under ' + - 'CC BY SA.'); - var i = options.layer.indexOf('-'); var provider = i == -1 ? options.layer : options.layer.slice(0, i); goog.asserts.assert(provider in ol.source.StamenProviderConfig); @@ -103,7 +105,7 @@ ol.source.Stamen = function(options) { layerConfig.extension; goog.base(this, { - attributions: [attribution], + attributions: ol.source.STAMEN_ATTRIBUTIONS, maxZoom: providerConfig.maxZoom, // FIXME uncomment the following when tilegrid supports minZoom //minZoom: providerConfig.minZoom,