2

I have a number of layers which share the same attribution. When more then one of them are visible at the same time I get something like this in my attribution control:

Company1 hyperlink1 Company2 hyperlink2 Company1 hyperlink1 Company1 hyperlink1

How can I avoid duplicates and have only unique records shown?

3

You want to make a single attribution object then re-use that across your layers, e.g.

var company1Attribution = new ol.Attribution({ html: 'Company1 hyperlink1'});

then in your source object, re-use that variable:

new ol.layer.Tile({
    source: new ol.source.WMTS({
        url: 'url',
        layer: 'layer1',
        ...
        attributions: [company1Attribution]
    })
})

new ol.layer.Tile({
    source: new ol.source.WMTS({
        url: 'url',
        layer: 'layer2',
        ...
        attributions: [company1Attribution]
    })
})

Openlayers should then only show one version of it on the map.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.