File size: 1,744 Bytes
1c61254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import streamlit as st
import folium
from streamlit_folium import folium_static

# Define hospitals data for Minnesota
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)]

# Create a map centered on Minnesota
m = folium.Map(location=[45.0, -94.0], zoom_start=7)

# Add markers for each hospital
for hospital in hospitals:
    folium.Marker(
        location=[hospital[2], hospital[3]],
        popup=f'{hospital[0]}<br>{hospital[1]}',
        icon=folium.Icon(color='red')
    ).add_to(m)

# Add waypoints for each hospital
waypoints = [(hospital[2], hospital[3]) for hospital in hospitals]
folium.plugins.AntPath(waypoints, delay=3000).add_to(m)

# Function to update the map when a button is clicked
def update_map(hospital_data):
    m.location = [hospital_data[2], hospital_data[3]]
    m.zoom_start = 13
    folium_static(m)

# Create a grid of buttons for selecting hospitals
col1, col2, col3 = st.columns(3)
with col1:
    if st.button(hospitals[0][0]):
        update_map(hospitals[0])
with col2:
    if st.button(hospitals[1][0]):
        update_map(hospitals[1])
with col3:
    if st.button(hospitals[2][0]):
        update_map(hospitals[2])

col4, col5, col6 = st.columns(3)
with col4:
    if st.button(hospitals[3][0]):
        update_map(hospitals[3])
with col5:
    if st.button(hospitals[4][0]):
        update_map(hospitals[4])

# Display the map in Streamlit
folium_static(m)