Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flyTo not zooming to exact given zoom #6828

Merged
merged 1 commit into from
Jun 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ui/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -852,7 +852,7 @@ class Camera extends Evented {
// s: The distance traveled along the flight path, measured in ρ-screenfuls.
const s = k * S;
const scale = 1 / w(s);
tr.zoom = startZoom + tr.scaleZoom(scale);
tr.zoom = k === 1 ? zoom : startZoom + tr.scaleZoom(scale);

if (this._rotating) {
tr.bearing = interpolate(startBearing, bearing, k);
Expand Down
7 changes: 7 additions & 0 deletions test/unit/ui/camera.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,13 @@ test('camera', (t) => {
t.end();
});

t.test('zooms to integer level without floating point errors', (t) => {
const camera = createCamera({zoom: 0.6});
camera.flyTo({ zoom: 2, animate: false });
t.equal(camera.getZoom(), 2);
t.end();
});

t.test('rotates to specified bearing', (t) => {
const camera = createCamera();
camera.flyTo({ bearing: 90, animate: false });
Expand Down