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

[Feature] Allow underzooming with single-copy world #4612

Closed
21 changes: 20 additions & 1 deletion src/geo/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,7 +785,26 @@ export class Transform {
let maxX = worldSize;
let scaleY = 0;
let scaleX = 0;
const {x: screenWidth, y: screenHeight} = this.size;
let {x: screenWidth, y: screenHeight} = this.size;

// For a single-world map, a user can "underzoom" the world to see it entirely in the viewport.
// This works by reducing the viewport's appararent size to a square with a side length equal to the smallest viewport dimension, then reduced by a factor `boundsRatio`.
// `minZoom` is obeyed in all cases.
if (!this._renderWorldCopies) {
// `boundsRatio` is the percentage of the bounds a user can exceed when panning and/or zooming, where a bound is measured from viewport edge to viewport center.
// The default is boundsRatio=0.5, which on a wide viewport means a user can pan and zoom out until the world's top and bottom edges are halfway between the viewport center and its top and bottom edges.
// _______________________________
// |viewport : } boundsRatio|
// | -———————————- |
// | |world: | |
// | | : | |
// | | * | |
// | | | |
// | -———————————- |
// |_____________________________|
const boundsRatio = 0.5;
screenWidth = screenHeight = (1.0 - boundsRatio) * Math.min(screenWidth, screenHeight);
}

if (this.latRange) {
const latRange = this.latRange;
Expand Down
Loading