Unexpected behavior when using flyTo and minZoom/maxZoom
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
Hi! Thanks for the wonderful software!
Playing with Map#flyTo this afternoon, I noticed an odd behavior when combined with a minZoom and maxZoom set on the map.
If the zoom param was set in the flyTo options object (or captured from the map's current zoom level) to the same value as the minZoom, the animation would "fly" to the new point, via a very distant location—say, [0, 0], or more like [90, 0] based on the direction of the animation.
For example, a map initialized like this…
const map = new mapboxgl.Map({
container: document.getElementById('map'),
center: [-73.94036665400398, 40.74010274792441],
pitchWithRotate: false,
dragRotate: false,
minZoom: 12,
maxZoom: 14
});
…and then asked to flyTo a nearby location…
map.flyTo({ center: [-73.95746808188471, 40.713585507497996] });
…we get taken very far out of our way, very rapidly—often causing hundreds of tile requests, but always ending up in the right place.
However! Zooming in at all, setting an initial zoom on the map to something other than the minZoom, or specifying an in-range zoom in the flyTo params makes for a normal animation.
Here's a link to a demo, using 0.38: http://jsbin.com/boriyelosa/edit?html,css,js,output
Let me know if there's any other info I can provide… for now, panTo is doing just fine, but I wanted to flag this, in case anyone else was up against a similar issue, or this could be considered a bug.
😻
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 at the Map#flyTo entry point and reproduce the reported case with minZoom 12, maxZoom 14, and no explicit zoom, comparing it with panTo and in-range zoom values. The fix is done when flying from the minimum zoom reaches the target normally without the distant excursion or excessive tile requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100