-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Add fractional zoom support to fitBounds and getBoundsZoom #3030
Conversation
37f82a7
to
1b35b12
Compare
1b35b12
to
23a8d20
Compare
var zoom = this.getMinZoom() - (inside ? 1 : 0), | ||
maxZoom = this.getMaxZoom(), | ||
var minZoom = this.getMinZoom(), | ||
maxZoom = Math.min(this.getMaxZoom(), 18) + step, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we hardcode z18 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need a non-infinite maxZoom in order to find a midpoint. Is there a better number to use? Or is the issue the use of a magic number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, e.g. in case there's a map with maxZoom = z20, fitBoundsZoom will always return 18 max. I think we should only limit it if it's infinite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Easy solution. New commit added.
Definitely a useful PR. I'll look into the possibility of calculating boundsZoom directly, without an iterative search, but if it turns out not to be possible, this will be good to merge. |
Any updates on this? Need this exact feature on current project and my searches found this thread. |
Superseded by #3523 |
Is it still possible to merge this in to master? Would be nice if fitBounds and getBoundsZoom can support fractional zoom deltas |
Adds a 'step' option to fitBounds (and equivalent 'step' parameter to getBoundsZoom), defaulting to 1, enabling these functions to use fractional zoom levels (#2382). For example, set 'step' to 0.25 for nearest quarter zoom level, i.e. 10, 10.25, 10.5, 10.75, and so on.
Optimizes getBoundsZoom with a binary search; previous implementation counted up from minZoom using whole numbers.