-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 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,33 @@ | ||
import streamlit as st | ||
|
||
st.set_page_config( | ||
page_title="streamlit-folium documentation", | ||
page_icon=":world_map:️", | ||
layout="wide", | ||
) | ||
|
||
|
||
"# Callbacks" | ||
|
||
""" | ||
Try moving the map and zooming in and out and see the callback in action. | ||
""" | ||
|
||
with st.echo(): | ||
import folium | ||
import streamlit as st | ||
|
||
from streamlit_folium import st_folium | ||
|
||
# center on Liberty Bell, add marker | ||
m = folium.Map(location=[39.949610, -75.150282], zoom_start=16) | ||
folium.Marker( | ||
[39.949610, -75.150282], popup="Liberty Bell", tooltip="Liberty Bell" | ||
).add_to(m) | ||
|
||
def callback(): | ||
st.toast(f"Current zoom: {st.session_state['my_map']['zoom']}") | ||
st.toast(f"Current center: {st.session_state['my_map']['center']}") | ||
|
||
# call to render Folium map in Streamlit | ||
st_data = st_folium(m, width=725, key="my_map", on_change=callback) |