Search code examples
javascriptopenlayersopenstreetmap

OpenLayers.Map change position of Attribution in JavaScript


I have included an OpenLayers.Map in my site per JavaScript:

var map = new OpenLayers.Map();
var mapnik = new OpenLayers.Layer.OSM();
map.addLayer(mapnik);

All works fine. Expect the position of the attribution (OpenStreetMap contributors). Are there any option move the attribution in the lower right corner?

Here is what i got currently: OpenStreetMap example


Solution

  • You can override the default OL style for this component:

    .olControlAttribution {
      left: 5px;
    }
    

    You can try this out by going to https://openlayers.org/en/latest/examples/attributions.html and executing the following JS code in your browser's console:

    document.getElementsByClassName('olControlAttribution')[0].style.left='5px'