jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.48k stars 363 forks source link

Saving map to html creates a blank webpage #1090

Open sromano opened 1 year ago

sromano commented 1 year ago

Saving the map to html runs without any issue. However, when opening the HTML, the page is blank.

Related old issue https://github.com/jupyter-widgets/ipyleaflet/issues/841 (although now the problem seems different so I'm opening a new on)

Tested on 0.17.2 and 0.17.1

In Colab I simply run:

!pip install -U ipyleaflet
import ipyleaflet
m = ipyleaflet.Map()
m.save('mymap.html')

and the resulting mymap file does not work in Chrome due to NaN in tile resources https://tile.openstreetmap.org/NaN/2047/2047.png

Same happens with the basic example:

from ipyleaflet import Map, basemaps, basemap_to_tiles

m = Map(
    basemap=basemap_to_tiles(basemaps.NASAGIBS.ModisTerraTrueColorCR, "2017-04-08"),
    center=(52.204793, 360.121558),
    zoom=4
)

Console shows 404 of different resources due to "NaN" in the TILEMATRIX https://map1.vis.earthdata.nasa.gov/wmts-webmerc/MODIS_Terra_CorrectedReflectance_TrueColor/default/2017-04-08/GoogleMapsCompatible_Level9/NaN/5/7.jpg

html.zip

sromano commented 1 year ago

It works in 0.17.0 (the error started on 0.17.1)

sromano commented 1 year ago

It seems related to zoom in tile changes: @martinRenou @ned2

martinRenou commented 1 year ago

It is probable that this PR https://github.com/jupyter-widgets/ipyleaflet/pull/1068 fixes it (only on the master branch for now) and that the next release will fix this

filipre commented 1 year ago

I just tested the master branch and it did not work for me. If I run pip freeze, I do see the local package

ipykernel                         6.20.2
ipyleaflet                        0.17.2      /Users/rene/Development/Notebooks/ipyleaflet
ipython                           8.9.0

but the save method still returns a blank map for me

m.save("my_map.html", title="My Map")

My best bet would be that it is somehow related to the introduced zoom_offset in 0.17.1 but I don't really understand why?

Empty Map: Screenshot 2023-02-02 at 17 51 18

400 Bad Request errors from openstreetmap.org Screenshot 2023-02-02 at 17 51 33

martinRenou commented 1 year ago

Using ipyleaflet master will not save you unfortunately, because your HTML page will not use your dev installation but the released one (fetched from online source). We need to release ipyleaflet.

philippjfr commented 1 year ago

Sorry to bug you guys but any timeline on getting a new release with the fix out?

alimanfoo commented 1 year ago

This is an issue for us as well, trying to build a jupyter book with ipyleaflet maps in it and hitting this. A release would be much appreciated 🙏🏻

cc @ahernank

alimanfoo commented 1 year ago

Btw we are instantiating a Map with an initial zoom level and we still see this, so perhaps #1068 will not fix this after all?

ahernank commented 1 year ago

@alimanfoo our issue (NaN in tiles, as described above) seems to be solved by using 0.17.0. FWIW, I tried using 0.16.0 earlier today, which also wasn't working..

martinRenou commented 1 year ago

Thanks for pinging. I'll do a release.

martinRenou commented 1 year ago

Done!