-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppose styling of feature group objects by rendering feature group b…
…efore generating js (#147) * Suppose styling of feature group objects by rendering feature group before generating js * Bump version * add geopandas * Click twice * Click text
- Loading branch information
Showing
6 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import folium | ||
import geopandas as gpd | ||
import shapely | ||
import streamlit as st | ||
|
||
from streamlit_folium import st_folium | ||
|
||
st.title("GeoJSON Styling") | ||
|
||
START_LOCATION = [37.7934347109497, -122.399077892527] | ||
START_ZOOM = 18 | ||
|
||
wkt = ( | ||
"POLYGON ((-122.399077892527 37.7934347109497, -122.398922660838 " | ||
"37.7934544916178, -122.398980265018 37.7937266504805, -122.399133972495 " | ||
"37.7937070646238, -122.399077892527 37.7934347109497))" | ||
) | ||
polygon_ = shapely.wkt.loads(wkt) | ||
gdf = gpd.GeoDataFrame(geometry=[polygon_]).set_crs(epsg=4326) | ||
|
||
style_parcels = {"fillColor": "red", "fillOpacity": 0.2} | ||
|
||
polygon_folium = folium.GeoJson(data=gdf, style_function=lambda x: style_parcels) | ||
|
||
map = folium.Map( | ||
location=START_LOCATION, zoom_start=START_ZOOM, tiles="OpenStreetMap", max_zoom=21 | ||
) | ||
fg = folium.FeatureGroup(name="Parcels") | ||
fg = fg.add_child(polygon_folium) | ||
|
||
st_folium( | ||
map, | ||
width=800, | ||
height=450, | ||
feature_group_to_add=fg, | ||
debug=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
streamlit>=1.13.0 | ||
folium>=0.13 | ||
jinja2 | ||
branca | ||
branca | ||
geopandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
setuptools.setup( | ||
name="streamlit_folium", | ||
version="0.15.0", | ||
version="0.15.1", | ||
author="Randy Zwitch", | ||
author_email="[email protected]", | ||
description="Render Folium objects in Streamlit", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ streamlit>1.11.1 | |
pytest>=7.1.2 | ||
folium>=0.13 | ||
pytest-playwright | ||
pytest-rerunfailures | ||
pytest-rerunfailures | ||
geopandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters