Tiles are not loaded in tile layer if native zoom is outside min & max zooms in leaflet 1.1.0
How to reproduce
- Leaflet version I'm using: 1.1.0
- Browser (with version) I'm using: Chrome Version 59.0.3071.115 (Official Build) (64-bit)
- OS/Platform (with version) I'm using: Windows 10
Create tile layer with following options:
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
minZoom: 15,
maxZoom: 18,
minNativeZoom: 14,
maxNativeZoom: 14
}).addTo(map);
What behaviour I'm expecting and which behaviour I'm seeing
Expecting behaviour is that for all zooms from 15 to 18 are loaded tiles of native zoom 14, with leaflet 1.0.3 it is working, but it does not work in leaflet 1.1.0.
Minimal example reproducing the issue
http://playground-leaflet.rhcloud.com/moho/edit?html,output
Hi,
Thank you for the detailed bug report and live test case!
Same bug when minNativeZoom is higher than maxZoom:
http://playground-leaflet.rhcloud.com/supi/1/edit?html,output
Similarly, this was working in version 1.0.3.
@perliedman seems to be another regression which is fixed by #5634 see http://176.95.37.29/vectortest/leaflet-5634.html with over- and underzoom
Hi,
I have just found another problem in tile loading behaviour regarding to this issue: 'tileload' and 'tileunload' events are in 1.0.3 fired when displayed tiles are loaded/unloaded, but in 1.1.0 these events are fired when native tiles are loaded/unloaded:
http://playground-leaflet.rhcloud.com/lufo/1/edit?html,console,output
Is it bug or feature of 1.1.0 ? Thanks, B.
@bolivab i guess that's also a regression fixed by #5634, which will be included in the upcoming release.
In my case the app systematically freezes the browser tab in chrome when map zoom > maxNativeZoom and leaflet version > 1.0.3.
So I had to revert to leaflet v1.0.3.
I would have liked to use http://playground-leaflet.rhcloud.com to demo this but the service is unavailable.
Freezing tabs is pretty bad. Can any body else reproduce this?
By the way: I can't use or test leaflet 1.1.0 because of this issue here: https://github.com/Leaflet/Leaflet.draw/issues/739
I am dearly hoping that nothing unexpected breaks when reverting from 1.2.0 to 1.0.3 :-|
Hi @barbalex,
Please can you open a new issue with the details of your situation? You might be in a different case, since I do not remember having a freezing issue when testing this problem.
As for the Playground, unfortunately I do not know for how long it will be down. But it is just a JSBin clone, so feel free to use whatever online service you like. E.g. you can build upon that Plunker: https://plnkr.co/edit/EHnxX98adVg1T6sDloCU?p=preview
@barbalex This bug is fixed with the current master. But there's no new release (should be 1.2.1). You can test it with a custom build of the master branch.
Hi @oliverheilig,
Thank you a lot for your PR and for pointing out the similarity between this issue and your PR!
Unless I am mistaken, PR #5634 does not seem to solve this precise issue unfortunately:
https://plnkr.co/edit/9PfsTxGzQFprd4gV0dLF?p=preview
(tested with current master at https://github.com/Leaflet/Leaflet/commit/93be1ae0a72737e98fe5b61b8090174f7128cb61)
Please can you open a new issue with the details of your situation?
@ghybs done: https://github.com/Leaflet/Leaflet/issues/5833
Hello Any news about the first bug (or regression) described in this issue ?
It still seems not fixed in the latest version (1.3.1).
I made a brand new jsfiddle to test it :
- the first layer is the one not working, with minZoom = 12, maxZoom = 18, and maxNativeZoom = 11.
- the second one is working, with minZoom = 10, maxZoom = 18, and no maxNativeZoom
https://jsfiddle.net/1hxdwLxn/16/
I tried with several leaflet versions, from cdnjs : 1.3.1 (the one currently on the jsfiddle), 1.2, 1.1, 1.0. The only version without the bug is 1.0, meaning the bug appeared in version 1.1, and was not fixed since.
Am I trying the wrong way or is the bug not fixed ?
Thanks in advance, bye
PS : the same jsfiddle, with leaflet version 1.0.3 (working) : https://jsfiddle.net/1hxdwLxn/18/
Hello @alfredott,
i've tested your jsfiddle, and while it may be a regression to 1.0.3, i don't see this as a bug. In your sample maxNativeZoom < minZoom, which doesn't seem to be a correct configuration.
As far as i can see, max(Native)Zoom should be min(Native)Zoom to get consistent behaviour, while the map.maxZoom/minZoom can be set to override the layer.max/minZoom settings. Then:
map.Zoom > layer.maxZoom => the layer is set invisible map.Zoom <= layer.maxZoom && map.Zoom > layer.maxNativeZoom => the layer does an "overzoom" by blurring the tiles fetched with the maxNativeZoom level.
The same applies symmetrically to minZoom / minNatvieZoom
I did a sample with different parameters and it looks totally consistent:
https://jsfiddle.net/apb5hzy9/9/
Oli
Hi @oliverheilig, Thanks for your answer !
I understand your description of native zooms' intended behaviour.
However, let me explain why I liked the fact that a layer was visible when layer.maxNativeZoom < layer.minZoom <= map.Zoom :
I have an "OSM like" server with all tiles precalculated from zooms 0 to 11. When a user requests a tile in these zooms, he's getting it instantly since the server already has calculated it. On the other hand, when he requests a tile from a higher zoom level (e.g. 13), the server is taking some time (around 5 seconds) to calculate it, which I find is a bit too long.
Thus, I'm using two layers, that have the same URL, but different min/max(Native)Zoom settings.
- The foreground layer is a classic one : minZoom=0, maxZoom=18
- The background layer has maxNativeZoom=11, and minZoom=12. It is visible only when map.Zoom is 12 or higher, since it is not useful for zooms 0 to 11. By using these two layers, when a user is navigating at zoom 13, he is getting a "pixelated" tile almost instantly (from the background layer, which zoom is 11) - instead of no tile at all -, and when the server is done calculating the zoom 13 tile, the user gets it and it shows up in the foreground.
The second jsfiddle I quoted (https://jsfiddle.net/1hxdwLxn/18/) is an example of this usage. All this only works with the previous behaviour of native zooms (version 1.0.3 and previous), and doesn't work with the new one (version 1.1 and later), since the background layer is not appearing anymore when its maxNativeZoom is lower than its minZoom. Also, it causes a bit more of network traffic than with a single layer, since users have to fetch both the pixelated tile and the classic one, at zooms 12 to 18.
A simple workaround to the regression is to give the background layer minZoom=11 instead of 12. Thus it will appear behind the foreground layer at zooms 11 to 18, instead of 12 to 18. At zoom 11, all tiles will be downloaded twice for nothing, which is a bit bad for network traffic.
To conclude, I understand your way of using maxNativeZoom, but I think there are others. For my use case, I liked its previous behaviour. Is there a way to go back to the previous behaviour simply ? (some code tweak for example) Or maybe someone has a better idea for my use case ?
Thanks again, have a nice day
My comment https://github.com/Leaflet/Leaflet/issues/5895#issuecomment-486815449 may or may not be helpful