Return original geometry for GeoJSON features in queryRenderedFeatures
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
Consider https://jsfiddle.net/w9bs8jot/. A GeoJSON Line feature is cut into multiple tiles and makes it impossible to query the entire line feature. A customer recently flagged this issue because they wanted users to be able to click on a line feature and get its start and/or end points.
## Design Alternatives
There's a potential workaround.
```
const selectedFeatures = map.queryRenderedFeatures(point);
selectedFeatures.forEach(feature => {
const source = map.getSource(feature.source);
// filter for the feature's original coordinates in the source
console.log('source data: ', source._data.features[0].geometry.coordinates);
})
```
## Design
We could add the original geometry to the features in a GeoJSON vector tile, although this may not be performant enough with large GeoJSON features.
Alternatively, queryRenderedFeatures needs a way to retrieve the original geometry for the feature.
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 with the linked JSFiddle and the queryRenderedFeatures API behavior described in the issue. Investigate how GeoJSON Line features are split across vector tiles and determine a design that lets callers retrieve the original geometry; done means a queried feature exposes the complete source geometry without making large features impractical.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100