Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

There should be right way to update attribution for source object #10922

Open
AvinashDalvi89 opened this issue Aug 10, 2021 · 1 comment
Open

Comments

@AvinashDalvi89
Copy link

Motivation

Reference : https://gis.stackexchange.com/questions/407876/how-to-update-source-property-attribution-in-mapbox-gl

I faced issue while updating attribution based on zoom level. Didn't find right way to do it.

I tried directly using

Code which am trying to add source to layer.

source = {
      type: 'raster',
      tiles: tileUrls,
      attribution : "Copyright"
      scheme,
      style,
      styles,
    };
map.addSource(`${this.asset.uuid}-data`, source);
const layer = {
        id: `${this.asset.uuid}-label`,
        type: 'raster',
        source: `${this.asset.uuid}-data`,
        minzoom: 0,
        maxzoom: 22,
      };
      map.addLayer(layer, this.asset.uuid);

Solution 1 :

source.attribution = 'text to be update';

Solution 2:

map.style.sourceCaches[`${this.asset.uuid}-data`]._source.attribution =  'text to be update';

Solution 3:

source.attribution = 'text to be update';
source.fire({type: 'data', data: {dataType: 'style'}});

Tried this above solution all works only for zoom in event not for zoom out. This is not correct way to do. It should be function like updateAttribution under source object.

Concepts

Implementation

@AvinashDalvi89
Copy link
Author

any update on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants