Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import folium
|
3 |
+
from streamlit_folium import folium_static
|
4 |
+
|
5 |
+
# Define hospitals data for Minnesota
|
6 |
+
hospitals = [('Mayo Clinic', 'Rochester', 44.023678, -92.466955), ('University of Minnesota Medical Center', 'Minneapolis', 44.971389, -93.240556), ('Hennepin County Medical Center', 'Minneapolis', 44.972078, -93.261769), ('Regions Hospital', 'St. Paul', 44.942936, -93.093457), ('Abbott Northwestern Hospital', 'Minneapolis', 44.955447, -93.268543)]
|
7 |
+
|
8 |
+
# Create a map centered on Minnesota
|
9 |
+
m = folium.Map(location=[45.0, -94.0], zoom_start=7)
|
10 |
+
|
11 |
+
# Add markers for each hospital
|
12 |
+
for hospital in hospitals:
|
13 |
+
folium.Marker(
|
14 |
+
location=[hospital[2], hospital[3]],
|
15 |
+
popup=f'{hospital[0]}<br>{hospital[1]}',
|
16 |
+
icon=folium.Icon(color='red')
|
17 |
+
).add_to(m)
|
18 |
+
|
19 |
+
# Add waypoints for each hospital
|
20 |
+
waypoints = [(hospital[2], hospital[3]) for hospital in hospitals]
|
21 |
+
folium.plugins.AntPath(waypoints, delay=3000).add_to(m)
|
22 |
+
|
23 |
+
# Display the map in Streamlit
|
24 |
+
folium_static(m)
|
25 |
+
|
26 |
+
# Create a grid of buttons for selecting hospitals
|
27 |
+
col1, col2, col3 = st.beta_columns(3)
|
28 |
+
with col1:
|
29 |
+
if st.button(hospitals[0][0]):
|
30 |
+
m.location = [hospitals[0][2], hospitals[0][3]]
|
31 |
+
with col2:
|
32 |
+
if st.button(hospitals[1][0]):
|
33 |
+
m.location = [hospitals[1][2], hospitals[1][3]]
|
34 |
+
with col3:
|
35 |
+
if st.button(hospitals[2][0]):
|
36 |
+
m.location = [hospitals[2][2], hospitals[2][3]]
|
37 |
+
|
38 |
+
col4, col5, col6 = st.beta_columns(3)
|
39 |
+
with col4:
|
40 |
+
if st.button(hospitals[3][0]):
|
41 |
+
m.location = [hospitals[3][2], hospitals[3][3]]
|
42 |
+
with col5:
|
43 |
+
if st.button(hospitals[4][0]):
|
44 |
+
m.location = [hospitals[4][2], hospitals[4][3]]
|