interpret undefined in place of a GeoJSON object as an empty FeatureCollection in addSource and setData
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Any thoughts on changing `addSource` so that
```js
map.addSource('id', {
type: 'geojson'
})
```
works without a data option (creating an empty FeatureCollection)
same for
```js
map.getSource('id').setData()
```
would reset the data to null
Avoids needing to spell out an empty FeatureCollection every time.
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 by tracing the map.addSource GeoJSON entry point and the GeoJSON source setData method to see how omitted data is currently handled. Check the existing source-related tests, if present, and verify that addSource without data creates an empty FeatureCollection while setData without an argument resets the data to null.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100