mapbox / mapbox/mapbox-gl-js

MapMouseEvent location incorrect inside UIKit grid

Open
#11,550 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :lady_beetle: needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

**mapbox-gl-js version 2.7.0**:

**Browser: Chrome 98.0.4758.102, Safari 13.1.2**:

### Steps to Trigger Behavior

1. Create a map inside an UIKit grid, add a point feature
2. Add the click event listener with feature querying based on the e.point event location
3. Click on the feature added in step 1
4. The clicked feature should be returned, but it is not

### Link to Demonstration
https://jsfiddle.net/Johan111/vywdncj0/2/
Check the logs in the console

### Expected Behavior
queryRenderedFeatures(e.point) should return the clicked feature

### Actual Behavior
queryRenderedFeatures(e.point) returns nothing,
but queryRenderedFeatures([e.originalEvent.layerX, e.originalEvent.layerY]) does

It seems to be related to the padding added by the UIKit grid style. The e.point is shifted from the e.originalEvent by the same amount as is the padding.

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 with the linked JSFiddle and reproduce the click behavior in a UIKit grid, comparing e.point with e.originalEvent.layerX and layerY. Trace the map click event coordinate calculation and its handling of grid padding; done means queryRenderedFeatures(e.point) returns the clicked feature in the reported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.