diff --git a/examples/attributions.html b/examples/attributions.html new file mode 100644 index 0000000000..50da53c693 --- /dev/null +++ b/examples/attributions.html @@ -0,0 +1,51 @@ + + + + + + + + + + + Attributions example + + + + + +
+ +
+
+
+
+
+ +
+ +
+

Attributions example

+

Example of a attributions visibily change on map resize, to collapse them on small maps.

+
+

See the attributions.js source to see how this is done.

+
+
attributions, openstreetmap
+
+ +
+ +
+ + + + + + + diff --git a/examples/attributions.js b/examples/attributions.js new file mode 100644 index 0000000000..a48645f0c8 --- /dev/null +++ b/examples/attributions.js @@ -0,0 +1,33 @@ +goog.require('ol.Map'); +goog.require('ol.View'); +goog.require('ol.control'); +goog.require('ol.control.Attribution'); +goog.require('ol.layer.Tile'); +goog.require('ol.source.OSM'); + +var attribution = new ol.control.Attribution({ + collapsible: false +}); +var map = new ol.Map({ + layers: [ + new ol.layer.Tile({ + source: new ol.source.OSM() + }) + ], + controls: ol.control.defaults({ attribution: false }).extend([attribution]), + renderer: exampleNS.getRendererFromQueryString(), + target: 'map', + view: new ol.View({ + center: [0, 0], + zoom: 2 + }) +}); + +function checkSize() { + var small = map.getSize()[0] < 600; + attribution.setCollapsible(small); + attribution.setCollapsed(small); +} + +$(window).on('resize', checkSize); +checkSize();