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.

max_native_zoom not working for TileLayer

See original GitHub issue

I was trying to serve a local TileLayer that only contains zoom 19 tiles with the following piece of code:

from ipyleaflet import Map, basemap_to_tiles

test = basemap_to_tiles(
    {
        "url": "http://localhost:8000/{z}/{y}/{x}.png",
        "max_zoom":21,
        "min_zoom":19,
        "max_native_zoom":19
    },
)

m = Map(
    center=[38.73855512843848, -9.129069282806583],
    zoom=19,
    max_zoom=21,
    basemap=test,
)
m

without any success, the output is an empty map. I started looking for the problem and I noticed that the request for the tiles was being made for zoom 18, instead of zoom 19, and since I don’t have any I couldn’t load any image.

Went on playing with the source code and once I changed the TileLayer max_native_zoom to 19, now I was getting the request for zoom 19.

class TileLayer(RasterLayer):
      _view_name = Unicode('LeafletTileLayerView').tag(sync=True)
      _model_name = Unicode('LeafletTileLayerModel').tag(sync=True)

      bottom = Bool(True).tag(sync=True)
      url = Unicode('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').tag(sync=True)
      min_zoom = Int(0).tag(sync=True, o=True)
      max_zoom = Int(18).tag(sync=True, o=True)
      min_native_zoom = Int(0).tag(sync=True, o=True)
      # Had to change max_native zoom directly in the source code from 18 to 19
      # max_native_zoom = Int(18).tag(sync=True, o=True) 
      max_native_zoom = Int(19).tag(sync=True, o=True) 
      tile_size = Int(256).tag(sync=True, o=True)
      attribution = Unicode('Map data (c) <a href="https://openstreetmap.org">OpenStreetMap</a> contributors').tag(
      ⦙   sync=True, o=True)
      detect_retina = Bool(False).tag(sync=True, o=True)
      no_wrap = Bool(False).tag(sync=True, o=True)
      tms = Bool(False).tag(sync=True, o=True)
      show_loading = Bool(False).tag(sync=True)
      loading = Bool(False, read_only=True).tag(sync=True)

      _load_callbacks = Instance(CallbackDispatcher, ())

From this point onwards I stopped understanding where the bug(if it is even a bug) comes from. Maybe JS implementation is not taking into account user param for max_native_zoom which makes the request wrong?

Note: Did not play with min_native_zoom, but most likely it suffers from the same problem

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RodrigoNeves95commented, Aug 25, 2021

Last update: it seems that what you said in your last message works and I did not try it yet (have no idea why, my bad)

Conclusion: everything works and it is! Thank you a lot for the rubber ducking.

1reaction
RodrigoNeves95commented, Aug 25, 2021

Pretty sure I tried it, but will double check it! Once I reach my computer again I will update you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet request non-existing tiles despite maxNativeZoom ...
I have this leaflet map with a tileLayer where maxNativeZoom is not working for some reason. If I zoom in further than the...
Read more >
The maxNativeZoom option of the layer is not being set when ...
I tested and verified that the maxNativeZoom option does work for all basemaps and lets a user "over zoom" without requesting new tiles...
Read more >
leaflet - Is there an issue with maxNativeZoom on Tile Layers ...
There are two main issues. The first issue is the minZoom and maxZoom are always being overwritten by the mapbox tile layer setting....
Read more >
maxNativeZoom not working (#2) · Issues - GitLab
maxNativeZoom to auto-scale the tiles when zooming in further than the layer provides tiles doesn't work. When zoomed in further than available ...
Read more >
Openlayers doesn't load tiles beyond zoom level 18?
so your demos are not using the maxNativeZoom and the different behaviour between openlayer and leaflet is due to the default configuration:
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