queryRenderedFeatures should account for z-offset properties
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
I want to interact with map features which are elevated (e.g. with line-z-offset, symbol-z-offset, fill-z-offset). For example, I can highlight an elevated line when hovered or click on it to trigger an event.
Unless i'm missing something, the following functions don't account for the z-offset:
- on click, on mouseover etc: These events only get fired if I click on the ground co-ordinates rather than the offset feature which wouldn't be intuitive for users
- QueryRenderedFeatures: No way to query features under the mouse which might be offset from the ground though might be better solved with...
- unproject / project: I may want to calculate the ground co-ordinates X metres below the pixel coordinates (e.g. to create geometry offset from the ground or QueryRenderedFeatures at that ground position)
## Design Alternatives
- on click/ on mouse over etc: I would expect the features which are visible at the mouse position to be returned, even if they are offset. Or perhaps this could be an optional parameter.
- QueryRenderedFeatures: Similar to above
- unproject / project: Add a parameter to give a value offset from the co-ordinates in a number of metres.
## Suggestion
I think adding the ability to incorporate a z-offset to the unproject/project functions might be the most beneficial short term, as it could be used in combination with QueryRenderedFeatures to achieve the desired result. However, one limitation is this is only beneficial if I know the z-offset of the features I want to query in advance.
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 reviewing the mentioned event handling, queryRenderedFeatures, and project/unproject entry points to understand how elevated features are currently considered. Before implementation, define the intended z-offset behavior and API scope; the work is done when the chosen interaction and projection behavior is specified and covered by appropriate tests.
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
- Needs clarification
- Newbie friendliness
- 35/100