Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exporting HTML map multiple times causes increasing file sizes #1098

Open
filipre opened this issue Feb 7, 2023 · 1 comment
Open

Exporting HTML map multiple times causes increasing file sizes #1098

filipre opened this issue Feb 7, 2023 · 1 comment

Comments

@filipre
Copy link

filipre commented Feb 7, 2023

Hi!

I need to generate multiple maps and save them to my system. I noticed that calling m.save() multiple times increases the size of the exported HTML map. Consider the following jupyter notebook

from ipyleaflet import Map

for i in range(20):
    m = Map(center=(48.0, 10.0), zoom=5)
    m.layout.height = "1000px"
    m.save(f"map_{i}.html", title=f"Map for {i}")

Even though I generate the same map 20 times, the file size differs on my system:
Screenshot 2023-02-07 at 11 43 42

Also consider the first and second html page
map_0.txt
map_1.txt

Notice that I am using version 0.17.0 because the save() method is broken in version 0.17.1 and 0.17.2 (newest). Any ideas how to resolve this?

Best,
René

@filipre
Copy link
Author

filipre commented Feb 8, 2023

Okay, it seems like jupyter-widgets/ipywidgets#3448 is the underlying issue. The following fix works for me, but I'd like to keep this issue open until ipyleaflet uses the fixed version (once its released)

from ipywidgets.widgets.widget import Widget 
from ipyleaflet import Map

for i in range(20):
    Widget.widgets.clear()
    m = Map(center=(48.0, 10.0), zoom=5)
    m.layout.height = "1000px"
    m.save(f"bug/map_{i}.html", title=f"Map for {i}")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant