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

Add fractional zoom support to fitBounds and getBoundsZoom #3030

Closed
wants to merge 3 commits into from

Conversation

cmgiven
Copy link

@cmgiven cmgiven commented Nov 15, 2014

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.

@cmgiven cmgiven force-pushed the fractional_fitBounds branch 4 times, most recently from 37f82a7 to 1b35b12 Compare November 16, 2014 11:18
@cmgiven cmgiven force-pushed the fractional_fitBounds branch from 1b35b12 to 23a8d20 Compare November 16, 2014 11:31
var zoom = this.getMinZoom() - (inside ? 1 : 0),
maxZoom = this.getMaxZoom(),
var minZoom = this.getMinZoom(),
maxZoom = Math.min(this.getMaxZoom(), 18) + step,
Copy link
Member

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?

Copy link
Author

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?

Copy link
Member

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.

Copy link
Author

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.

@mourner
Copy link
Member

mourner commented Nov 20, 2014

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.

@mourner mourner added this to the 1.0 milestone Nov 20, 2014
@wjthomas9
Copy link

Any updates on this? Need this exact feature on current project and my searches found this thread.

@IvanSanchez IvanSanchez mentioned this pull request Jun 9, 2015
2 tasks
@yohanboniface yohanboniface modified the milestones: 1.0-beta3, 1.0 Oct 12, 2015
@IvanSanchez
Copy link
Member

Superseded by #3523

@ronaldcurtis
Copy link

Is it still possible to merge this in to master? Would be nice if fitBounds and getBoundsZoom can support fractional zoom deltas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants