Skip to content

Commit

Permalink
Dont fail on bounds (#68)
Browse files Browse the repository at this point in the history
* Don't fail if the bounds don't generate properly

* Bump version
  • Loading branch information
blackary authored May 26, 2022
1 parent 4c5f69a commit f4f3bde
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setuptools.setup(
name="streamlit_folium",
version="0.6.11",
version="0.6.12",
author="Randy Zwitch",
author_email="[email protected]",
description="Render Folium objects in Streamlit",
Expand Down
7 changes: 6 additions & 1 deletion streamlit_folium/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ def bounds_to_dict(bounds_list: List[List[float]]) -> Dict[str, Dict[str, float]
},
}

try:
bounds = fig.get_bounds()
except AttributeError:
bounds = [[None, None], [None, None]]

component_value = _component_func(
fig=leaflet,
id=m_id,
Expand All @@ -157,7 +162,7 @@ def bounds_to_dict(bounds_list: List[List[float]]) -> Dict[str, Dict[str, float]
"last_object_clicked": None,
"all_drawings": None,
"last_active_drawing": None,
"bounds": bounds_to_dict(fig.get_bounds()),
"bounds": bounds_to_dict(bounds),
"zoom": fig.options.get("zoom") if hasattr(fig, "options") else {},
"last_circle_radius": None,
"last_circle_polygon": None,
Expand Down

0 comments on commit f4f3bde

Please sign in to comment.