commit 6d8d0309070a7b591dee02fb6260579997a41873 parent 2fbce176bf5a805b6138cf49358371b132fcfe7d Author: Sergey Orlov <wladimirych@gmail.com> Date: Sat, 12 Dec 2020 18:24:08 +0100 Hide attribution control on small screens Diffstat:
M | src/App.js | | | 18 | ++++++++++++++++-- |
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/App.js b/src/App.js @@ -123,10 +123,24 @@ function setUp() { /* controls bottom-left corner */ - L.control.attribution({ + const attribution = L.control.attribution({ position: 'bottomleft', prefix: false, - }).addTo(map); + }); + map.on('resize', function() { + if (map.getSize().y > 567) { + map.addControl(attribution); + // Hack to keep control at the bottom of the map + const container = attribution._container; + const parent = container.parentElement; + parent.appendChild(container); + } else { + map.removeControl(attribution); + } + }); + if (map.getSize().y > 567) { + map.addControl(attribution); + } const printControl = new L.Control.PrintPages({position: 'bottomleft'}) .addTo(map)