Skip to content

Commit

Permalink
Convert initial bounds from list-style to dict-style in default (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackary authored May 11, 2022
1 parent 5448c2c commit b3616cf
Show file tree
Hide file tree
Showing 2 changed files with 16 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.7",
version="0.6.8",
author="Randy Zwitch",
author_email="[email protected]",
description="Render Folium objects in Streamlit",
Expand Down
16 changes: 15 additions & 1 deletion streamlit_folium/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib
import os
import re
from typing import Dict, List

import branca
import folium
Expand Down Expand Up @@ -127,6 +128,19 @@ def st_folium(
if "drawnItems" not in leaflet:
leaflet += "\nvar drawnItems = [];"

def bounds_to_dict(bounds_list: List[List[float]]) -> Dict[str, Dict[str, float]]:
southwest, northeast = bounds_list
return {
"_southWest": {
"lat": southwest[0],
"lng": southwest[1],
},
"_northEast": {
"lat": northeast[0],
"lng": northeast[1],
},
}

component_value = _component_func(
fig=leaflet,
id=m_id,
Expand All @@ -138,7 +152,7 @@ def st_folium(
"last_object_clicked": None,
"all_drawings": None,
"last_active_drawing": None,
"bounds": fig.get_bounds(),
"bounds": bounds_to_dict(fig.get_bounds()),
"zoom": fig.options.get("zoom") if hasattr(fig, "options") else {},
},
)
Expand Down

0 comments on commit b3616cf

Please sign in to comment.