JSFiddle - React, Tailwind, and code Playground

by Kenny806

HTML

<script src="http://openlayers.org/en/v3.0.0/build/ol.js"></script>
<link rel="stylesheet" href="http://openlayers.org/en/v3.0.0/css/ol.css">
<div style="width:80%; height:80%; position:fixed; border: 1px solid;" id="map"></div>

JavaScript

//create own attribution for easier referencing.
//it could also be found from map.getControls()
var attribution = new ol.control.Attribution();
attribution.setCollapsed(true);

var map = new ol.Map({
  layers: [
    new ol.layer.Tile({
      source: new ol.source.OSM()
    })
  ],
  //add controls with referenced attribution
  controls: ol.control.defaults({ attribution: false }).extend([attribution]),
  target: 'map',
  view: new ol.View({
    center: [0, 0],
    zoom: 2
  })
});


$(".ol-attribution").click(function() {
    attribution.setCollapsed(true);
    alert("It's showing the attribution anyway");
});