max_native_zoom not working for TileLayer
See original GitHub issueI 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:
- Created 2 years ago
- Comments:9 (4 by maintainers)
Top GitHub Comments
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.
Pretty sure I tried it, but will double check it! Once I reach my computer again I will update you!