Add attributions example

Showing how to dynamically change collapsed/collapsible properties for ≠
map sizes.
This commit is contained in:
Antoine Abt
2014-06-23 12:34:37 +02:00
parent 4f087f1b84
commit f0f9291161
2 changed files with 84 additions and 0 deletions

33
examples/attributions.js Normal file
View File

@@ -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();