There should be right way to update attribution for source object
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## 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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the map.addSource entry point and the source.attribution handling described in the issue; reproduce the raster-source case while zooming in and out. Done means a supported attribution update path is defined and verified to behave consistently in both directions, with relevant tests or documentation added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100