map.setStyle() does not preserve render of inline geojson data
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
`map.setStyle()` causes the render of the inline geojson data to disappear, despite `map.getStyle().sources.[sourceId].data` showing data to be present.
I can force the render by calling `setData()`, so I do have a workaround, but it would be nice if the workaround isn't needed.
```
const style = map.getStyle()
// modify style as desired
map.setStyle(style)
// force a render of inline geojson, otherwise it just disappears
Object.keys(style.sources).forEach(sourceId => {
const { type, data } = style.sources[sourceId]
if (type === 'geojson' && typeof data !== 'string') {
map.getSource(sourceId).setData(data)
}
})
```
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
Reproduce the issue by applying map.setStyle() to a style containing inline GeoJSON, then inspect map.getStyle() and compare the render before and after. Verify that the inline GeoJSON remains rendered without the workaround's setData() calls, while preserving the existing source data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100