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

Do an explicit undefined check on fallback zoom #10

Merged
merged 1 commit into from
Mar 30, 2018

Conversation

alexthemark
Copy link
Contributor

Hey @ghybs ,

Thanks for the awesome tile fallback library!

I was playing around when my tile server started erroring out, and I think there's a bug when minNativeZoom is set to zero, and leaflet fails to fetch any tiles.

If minNativeZoom is set to zero and you can't receive any tiles from your tile source you'll enter this loop:

fallbackZoom reaches 1
tile._fallbackZoom becomes 0
0 is not less than 0, so fallbackZoom < layer.options.minNativeZoom is false, and we don't return the error tile.

... so we request a tile and loop around

tile._fallbackZoom is 0, which is falsy, so we set tile._fallbackZoom to originalCoords.z -1. We begin our loop again.

By checking for an explicit undefined value, we won't hit that loop -- tile._fallbackZoom will be set to -1, it will be less than zero, and we'll set the error tile.

Hey @ghybs, 

Thanks for the awesome fallback library!

I was playing around when my tile server started erroring out, and I think there's a bug when minNativeZoom is set to zero, and leaflet fails to fetch any tiles.

If minNativeZoom is set to zero and you can't receive any tiles from your tile source you'll enter this loop:

fallbackZoom reaches 1
tile._fallbackZoom becomes 0
0 is not less than 0, so fallbackZoom < layer.options.minNativeZoom is false, and we don't return the error tile.

... so we request a tile and loop around

tile._fallbackZoom is 0, which is falsy, so we set tile._fallbackZoom to originalCoords.z -1. We begin our loop again. 

By checking for an explicit undefined value, we won't hit that loop -- tile._fallbackZoom will be set to -1, it will be less than zero, and we'll set the error tile.
@ghybs
Copy link
Owner

ghybs commented Mar 30, 2018

Hi,

Thank you for submitting your PR!

Nice catch!

@ghybs ghybs merged commit c3bcc80 into ghybs:master Mar 30, 2018
@ghybs ghybs mentioned this pull request Mar 30, 2018
@alexthemark alexthemark deleted the patch-2 branch March 30, 2018 13:46
@alexthemark
Copy link
Contributor Author

Thanks for merging! would you mind releasing a patch release?

@ghybs
Copy link
Owner

ghybs commented Apr 3, 2018

Hi,

Shipped in v1.0.4

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.

None yet

2 participants