mapbox / mapbox/mapbox-gl-js

`["distance-from-center"]` calculation is broken with non-mercator projections

Open
#11,243 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

**mapbox-gl-js version**: v2.6.0-beta.2

**browser**: Any

### Steps to Trigger Behavior

1. Use `http://localhost:9966/debug/dynamic-filter.html`
2. Use the mouse tooltip to look at `distance-from-center` values
3. At high zooms when the map is undistorted to `mercator`, the calculations are still inaccurate.

### Expected Behavior
Value is 0 near the center, >0 above and <0 below, independent of zoom

https://user-images.githubusercontent.com/1449257/140559433-42bad370-8d40-492c-826f-1642edba74d8.mov

### Actual Behavior
Values are wildly large

https://user-images.githubusercontent.com/1449257/140559476-dd7c4334-0c04-42dc-9c76-44140fd8e0c7.mov

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

Run debug/dynamic-filter.html and use the mouse tooltip to reproduce the distance-from-center values at high zoom with a non-Mercator projection. Trace the calculation from this debug entry point, then verify that values are near 0 at the center, positive above, negative below, and independent of zoom.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.