From d1cecf3be1acf96967424a2e1507eb3c933652f1 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 6 Oct 2009 18:46:06 +0000 Subject: [PATCH] Adding an option to avoid duplicate attribution. Thanks Marc Jansen for this nice contribution. Without wanting to gush, I think this should be a model contribution because: 1. it is a simple change 2. with a nice example that clearly demonstrates the benefit 3. it includes tests! 4. and Marc wrote a note to the dev list with links to the ticket r = me (closes #2266) git-svn-id: http://svn.openlayers.org/trunk/openlayers@9720 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf --- .../attribution-eliminated-duplicates.html | 78 +++++++++++++++++++ lib/OpenLayers/Control/Attribution.js | 14 +++- tests/Control/Attribution.html | 20 +++++ 3 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 examples/attribution-eliminated-duplicates.html diff --git a/examples/attribution-eliminated-duplicates.html b/examples/attribution-eliminated-duplicates.html new file mode 100644 index 0000000000..8bf184e1d8 --- /dev/null +++ b/examples/attribution-eliminated-duplicates.html @@ -0,0 +1,78 @@ + + + OpenLayers Attribution Example (attribute eliminateDuplicates) + + + + + + +

OpenLayers Attribution Example (attribute eliminateDuplicates)

+
+

+ Demonstrates the use of the attribute eliminateDuplicates for Attribution-controls +

+

Standard Usage of the control

+
+

Use the attribute eliminateDuplicates to get rid of redundant Information

+
+
+ + diff --git a/lib/OpenLayers/Control/Attribution.js b/lib/OpenLayers/Control/Attribution.js index 2395e019d9..6cb8a48ddf 100644 --- a/lib/OpenLayers/Control/Attribution.js +++ b/lib/OpenLayers/Control/Attribution.js @@ -22,6 +22,12 @@ OpenLayers.Control.Attribution = * {String} String used to seperate layers. */ separator: ", ", + + /** + * APIProperty: eliminateDuplicates + * {Boolean} shall already present attribution strings be eliminated when other layers have the same attribution string? + */ + eliminateDuplicates: false, /** * Constructor: OpenLayers.Control.Attribution @@ -81,9 +87,13 @@ OpenLayers.Control.Attribution = for(var i=0, len=this.map.layers.length; i