Do an explicit undefined check on fallback zoom #10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.