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

Memory space increases each time a python ipyleaflet map is saved #1221

Open
manikobi opened this issue Jul 24, 2024 · 0 comments
Open

Memory space increases each time a python ipyleaflet map is saved #1221

manikobi opened this issue Jul 24, 2024 · 0 comments

Comments

@manikobi
Copy link

I noticed a weird behaviour when creating maps with ipyleaflet. Every time I create an ipyleaflet map and want to save it as an html file the resulting file gets iteratively bigger and bigger in memory. When checking the resulting html file I recognized, that the layers and also all control elements get not substituted but duplicated every time I save a map.
As I am running something similiar in a for loop the files need consequently a huge amount memory space. I attached a simple script to reproduce the problem:

from ipyleaflet import Map, LayersControl, GeoData
from shapely import Point
from geopandas import GeoDataFrame


# Create a dummy GeoDataFrame
points = GeoDataFrame(geometry = [Point(3.01331, 50.97503),
                                  Point(2.67155, 51.13195),
                                  Point(2.81919, 51.18672),
                                  Point(2.81795, 51.18855),
                                  Point(3.13164, 51.02534),
                                  Point(2.74758, 50.79735),
                                  Point(2.64778, 51.10591),
                                  Point(2.63007, 51.09972),
                                  Point(2.66865, 51.07438),
                                  Point(2.74761, 50.72729)],
                      crs = 4326)


# Convert GeoDataFrame to ipyleaflet Geo_Dataframe
points = GeoData(geo_dataframe=points,
                 point_style={'radius': 5, 'fillColor': 'blue','weight': 3},
                 name = 'Points')

# Initialize ipyleaflet map                 
m = Map(center=(50.95350377279631, 2.8110499565836227), zoom=10)

m.layout.width = '50%'
m.layout.height = '700px'
m.add_control(LayersControl(position="topright"))

# Add Geo_Dataframe to map
m.add_layer(points)


# Save as html
m.save("Map.html")
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