Skip to content

Commit

Permalink
remove index = 0 for selenium compatibility
Browse files Browse the repository at this point in the history
add set_parent_for_children function needed after unpickling
  • Loading branch information
BastienGauthier committed Oct 6, 2023
1 parent d5663ad commit 1254fe9
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions folium/folium.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,18 @@ def __init__(
self.add_child(child, name = key)
else: # Initialize the tiles
if isinstance(tiles, TileLayer):
self.add_child(tiles, index = 0)
self.add_child(tiles)
elif tiles:
tile_layer = TileLayer(
tiles=tiles, attr=attr, min_zoom=min_zoom, max_zoom=max_zoom, index = 0
tiles=tiles, attr=attr, min_zoom=min_zoom, max_zoom=max_zoom
)
self.add_child(tile_layer, name=tile_layer.tile_name)

def set_parent_for_children(self) -> None:
for _, child in self._children.items():
child._parent = self
return None

def _repr_html_(self, **kwargs) -> str:
"""Displays the HTML Map in a Jupyter notebook."""
if self._parent is None:
Expand Down Expand Up @@ -516,7 +521,7 @@ def keep_in_front(self, *args: Layer) -> None:
for obj in args:
self.objects_to_stay_in_front.append(obj)

def map_reduce(map_instance):
def map_pickler(map_instance):
return (Map, (
map_instance.location,
map_instance.width,
Expand Down Expand Up @@ -544,4 +549,4 @@ def map_reduce(map_instance):
map_instance._children,
))

copyreg.pickle(Map, map_reduce)
copyreg.pickle(Map, map_pickler)

0 comments on commit 1254fe9

Please sign in to comment.