mapbox / mapbox/mapbox-gl-js

queryRenderedFeatures should account for z-offset properties

Open
#13,310 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

auto-triaged bug :lady_beetle:
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.