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.

TileLayer: Simplify the max_zoom logic

See original GitHub issue

I’m hoping/thinking this might just be a user issue on my end, but it is currently appearing that TileLayer’s max_zoom value is capped at 18 even after setting it to a higher value. For example, in this MyBinder demo’s example.ipynb: https://mybinder.org/v2/gh/banesullivan/localtileserver-demo/HEAD which I have modified below:

from localtileserver import examples, get_leaflet_tile_layer, TileClient
from ipyleaflet import Map

# Create a tile server from an raster URL
oam = TileClient('https://oin-hotosm.s3.amazonaws.com/59c66c5223c8440011d7b1e4/0/7ad397c0-bba2-4f98-a08a-931ec3a6e943.tif')

# Create ipyleaflet TileLayer from that server
# Please note that all extra kwargs are passed to `TileLayer`
oam_layer = get_leaflet_tile_layer(oam, max_zoom=24, show_loading=True)

# Create ipyleaflet map, add layers, add controls, and display
m = Map(center=oam.center(), zoom=20, max_zoom=100)
m.add_layer(oam_layer)
m
>>> from ipyleaflet import TileLayer
>>> isinstance(oam_layer, TileLayer)
True
>>> oam_layer.max_zoom
24

No matter how much I zoom in, I can watch the network tab in the browser and see that the tile requests coming from that TileLayer never exceed zoom level 18, e.g., .../proxy/41129/api/tiles/18/85161/117721.png

Screen Shot 2022-02-10 at 10 29 10 AM

I know that this image source has a max zoom level of 24 and localtileserver will continue serving tiles at whatever zoom level is requested regardless of the cap in the data source.

So I’m wondering what is missing here to make sure TileLayer can continue to fetch tiles beyond zoom level 18.

Additional context

ipyleaflet CesiumJS
in the share mybinder https://tileserver.banesullivan.com/?filename=https%3A%2F%2Foin-hotosm.s3.amazonaws.com%2F59c66c5223c8440011d7b1e4%2F0%2F7ad397c0-bba2-4f98-a08a-931ec3a6e943.tif
Screen Shot 2022-02-10 at 10 35 25 AM Screen Shot 2022-02-10 at 10 35 45 AM

This is very high resolution imagery and it’d be fantastic to visualize at full resolution with ipyleaflet

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:18 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
martinRenoucommented, Apr 22, 2022

@banesullivan you should not need to provide a max_zoom for the Map anymore, its value is None by default (like in LeafletJS) which means the map takes the max value of the tile layers max zoom automatically.

1reaction
martinRenoucommented, Feb 22, 2022

@XingongLi @giswqs As @davidbrochart was saying, I understand you need to set the max_native_zoom property as well.

For example, - I think max_zoom of TileLayer should be set to None such that the tiles are never turned off by default when zooming passed them, instead the images should be scaled - the max_zoom of the TileLayer could, by default, match the max_native_zoom. This would prevent the tiles from disappearing before reaching the maximum zoom. - the Map’s max_zoom could be reset to the TileLayer in the Map with the highest zoom level if above 18. - If setting zoom on Map to something greater than the default max_zoom of 18, max_zoom should be increased

@banesullivan I agree we should simplify this and this sounds like a sensible approach. We could also probably remove the Map’s max_zoom property from the Python API and handle it ourselves in ipyleaflet’s JavaScript code.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Recipe specification | Mapbox Tiling Service
This sample recipe uses the normal simplification of 4 at most zoom levels, but reduces the simplification to 1 at the highest zoom...
Read more >
Min/Max zoom levels for a TileLayer - GIS Stack Exchange
According to the openlayers documentation, ol.source.XYZ has a minZoom and maxZoom parameter. However these do not show the desired effect.
Read more >
Openlayers 6.3.1 - rendering tilelayers - Stack Overflow
I have found a solution, not perfect, but the performance is better. map.on('movestart', () => { layers.forEach(layer => { layer.
Read more >
Azure Maps Web SDK best practices - Microsoft Learn
Set the max zoom option of GeoJSON data sources. The DataSource class converts raw location data into vector tiles local for on-the-fly ...
Read more >
Author a map for vector tile creation—ArcGIS Pro
A vector tile layer is a set of web-accessible tiles that are created from a ... but the offset strokes will appear simplified...
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