Autoscaling behavior when zooming past a layer's maxZoom
See original GitHub issueI’m not sure if this is a bug or a misinterpreation of the documentation.
I’m working with a tile source whose maximum zoom level is 18. We want the user to be able to zoom in up to level 21, so I assumed that we’d just need to set the map to maxZoom: 21
and the layer to maxNativeZoom: 18
, and the layer would autoscale the tiles as necessary for zoom levels higher than 18.
However, when I set just these two properties, the layer failed to render any tiles for zoom levels higher than 18. I found that I also had to set the tile layer to maxZoom: 21
to get it to autoscale the tiles as expected.
If this is the intended behavior, I think the documentation should state that the layer’s maxZoom property needs to be explicitly set, otherwise it won’t render any tiles for zoom levels higher than the default (18).
Here’s sample code that demonstrates the issue:
var map = L.map('map', {
center: [51.505, -0.09],
zoom: 18,
maxZoom: 21
});
L.tileLayer('https://{s}.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
subdomains: ['server', 'services'],
maxNativeZoom: 18,
// this MUST be set in order for the tiles to be autoscaled at zoom levels > 18
maxZoom: 21
}).addTo(map);
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
Gah, just hit this myself: https://jsfiddle.net/Pe5xU/765/
Currently it’s possible to zoom (both programmatically and manually) up to
map.maxZoom
, pastlayer.maxNativeZoom
, ending up with a grey box - see the fiddle above. It’s as iflayer.maxNativeZoom
is ignored (compare map1 and map2 in the fiddle above).Either zooming controls need limited to
layer.maxNativeZoom
or tiles need up-scaled for levels greater thanlayer.maxNativeZoom
.The need to explicitly set
layer.maxZoom
for each layer feels counter-intuitive and seems like needless code repetition (think 20 layers, all with differentmaxNativeZoom
). I agree thatlayer.maxZoom
should take precedent overmap.maxZoom
, but only when explicitly given. When onlylayer.maxNativeZoom
andmap.maxZoom
are given, I too would expect the tiles to scale-up at levels >layer.maxNativeZoom
.Hi @danielduhh,
First of all it would be much more interesting for everyone (and you in particular, so you get more relevant help) if you explain your situation: why do you get autoscaled tiles in the middle of crisp / normal tiles? This looks very strange if you are using
maxNativeZoom
option, which should apply to your entire Tile Layer, not just a few tiles here and there.The most probable explanation I have is that the blurred areas in your screenshot are not actually tiles, but just pixels of a much bigger tile (i.e. your current zoom is much bigger than
maxNativeZoom
) with transparent pixels, through which we see another crisp base map.In that case, you would just decrease the
maxZoom
option of the Tile Layer on which you have applied amaxNativeZoom
. But that depends whether you do want to still have that Tile Layer available at that zoom or not.If you need further help, please consider posting your question / issue on Stack Overflow, where you will reach a much wider audience.