Attribution
Quick answer
Attribution is the ol.control.Attribution collapsible copyright control that aggregates attributions declared by visible layers and sources. Add it through map.addControl or let the default controls create it, then tune className, collapsible, collapsed, tipLabel and target. The control only displays text supplied via each source's attributions option, so it never generates content on its own.
new ol.control.Attribution( options )
Key points
- Only visible layers contribute text; toggling layer visibility updates the panel automatically.
- collapsed defaults to true, while collapsible lets users expand the collapsed panel.
- getCollapsed and setCollapsed read or change state; getElement returns the control DOM node.
Example
var osm = new ol.layer.Tile({
source: new ol.source.OSM({
attributions: '© OpenStreetMap contributors'
})
});
var wms = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'https://example.com/geoserver/wms',
params: { LAYERS: 'demo:landuse' },
attributions: '数据来源:市规划院'
}),
visible: false
});
var attribution = new ol.control.Attribution({ collapsed: false });
map.addControl(attribution);
Notes
- The control itself produces no text, so without attributions on sources the panel stays empty.
- Supplying a custom target detaches it from the default control container, so other controls no longer move with it.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Attribution. https://www.jingweizhi.com/en/openlayers/api/attribution.html (accessed 2026-11-03).