mapbox / mapbox/mapbox-gl-js

map.flyTo avoids crossing the antimeridian when projection is globe

Open
#12,779 1 comment 4 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**: 2.15.0

**browser**: Firefox 114.0.2 (or latest chrome also)

### Steps to Trigger Behavior

1. Try to fly from somewhere far east in the eastearn hemisphere to somewhere west in the western hemisphere.

With a globe projection, the map will go westwards (around the world), while other projections like the mercator projection will go eastwards (the shorter route).
This is related to #2071 and #1853.

### Link to Demonstration

https://github.com/mapbox/mapbox-gl-js/assets/64247965/8aa6fd6a-744f-441c-9e3c-6456bb41fde9

Code to reproduce:
```
map.flyTo({
center: [180, 0],
});
setTimeout(() => {
map.flyTo({
center: [-180, 0],
});
}, 2500);
```
### Expected Behavior
Take the shortest possible path.

### Actual Behavior
Stays on w=0 and goes "the wrong way around" the globe.

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 at the map.flyTo entry point and reproduce the transition from [180, 0] to [-180, 0] with globe projection. Compare the route with the mercator behavior and verify that the globe animation takes the shortest path around the antimeridian.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.