question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Autoscaling behavior when zooming past a layer's maxZoom

See original GitHub issue

I’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:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
koniucommented, Feb 25, 2017

Gah, just hit this myself: https://jsfiddle.net/Pe5xU/765/

Currently it’s possible to zoom (both programmatically and manually) up to map.maxZoom, past layer.maxNativeZoom, ending up with a grey box - see the fiddle above. It’s as if layer.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 than layer.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 different maxNativeZoom). I agree that layer.maxZoom should take precedent over map.maxZoom, but only when explicitly given. When only layer.maxNativeZoom and map.maxZoom are given, I too would expect the tiles to scale-up at levels > layer.maxNativeZoom.

0reactions
ghybscommented, Jun 22, 2017

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 a maxNativeZoom. 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Getting OpenLayers to scale past nativeZoom like Leaflet?
And you will need to set maxZoom to 18 in your view. So when the view will change to zoom level 17 and...
Read more >
Why do some layers turn on or off as I zoom?
When autoscale is enabled, Maptitude checks the scale each time a map is drawn and decides whether each layer should be drawn. If...
Read more >
Setting a specific zoom and maxZoom on a layer only if there ...
I have a tile layer (using OpenTopoMap) and have set a default zoom level of 13 . But some tiles in certain areas...
Read more >
plotly.graph_objects.Layout — 5.11.0 documentation
Sets the maximum zoom level (mapbox.layer.maxzoom). At zoom levels equal to or greater than the maxzoom, the layer will be hidden. minzoom. Sets...
Read more >
Real-Time Vector Graphics for C/C++, Java, C#/.NET, HTML5 ...
GLG Map Server New Features and Enhancements Open Street Map Dataset Enhanced Zooming New Layer Attributes Miscellaneous Map Server Enhancements Bug Fixes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found