Spaces:
Runtime error
Runtime error
| import streamlit as st | |
| import folium | |
| from streamlit_folium import folium_static | |
| from folium.plugins import MarkerCluster | |
| # Define Minnesota medical centers data | |
| minnesota_med_centers = [ | |
| ('Mayo Clinic', 44.0224, -92.4658, 'General medical and surgical', 'Rochester'), | |
| ('University of Minnesota Medical Center', 44.9721, -93.2595, 'Teaching hospital', 'Minneapolis'), | |
| ('Abbott Northwestern Hospital', 44.9526, -93.2622, 'Heart specialty', 'Minneapolis'), | |
| ('Regions Hospital', 44.9558, -93.0942, 'Trauma center', 'St. Paul'), | |
| ('St. Cloud Hospital', 45.5671, -94.1989, 'Multiple specialties', 'St. Cloud'), | |
| ('Park Nicollet Methodist Hospital', 44.9304, -93.3640, 'General medical and surgical', 'St. Louis Park'), | |
| ('Fairview Ridges Hospital', 44.7391, -93.2777, 'Community hospital', 'Burnsville'), | |
| ('Mercy Hospital', 45.1761, -93.3099, 'Acute care', 'Coon Rapids'), | |
| ('North Memorial Health Hospital', 45.0131, -93.3246, 'General medical and surgical', 'Robbinsdale'), | |
| ('Essentia Health-Duluth', 46.7860, -92.1011, 'Community hospital', 'Duluth'), | |
| ('M Health Fairview Southdale Hospital', 44.8806, -93.3241, 'Community hospital', 'Edina'), | |
| ('Woodwinds Health Campus', 44.9272, -92.9689, 'Community hospital', 'Woodbury'), | |
| ('United Hospital', 44.9460, -93.1052, 'Acute care', 'St. Paul'), | |
| ('Buffalo Hospital', 45.1831, -93.8772, 'Community hospital', 'Buffalo'), | |
| ('Maple Grove Hospital', 45.1206, -93.4790, 'Community hospital', 'Maple Grove'), | |
| ('Olmsted Medical Center', 44.0234, -92.4610, 'General medical and surgical', 'Rochester'), | |
| ('Hennepin Healthcare', 44.9738, -93.2605, 'Teaching hospital', 'Minneapolis'), | |
| ('St. Francis Regional Medical Center', 44.7658, -93.5143, 'Community hospital', 'Shakopee'), | |
| ('Lakeview Hospital', 45.0422, -92.8137, 'Community hospital', 'Stillwater'), | |
| ('St. Luke\'s Hospital', 46.7831, -92.1043, 'Community hospital', 'Duluth') | |
| ] | |
| # Create a map centered on Minnesota | |
| m = folium.Map(location=[45.6945, -93.9002], zoom_start=6) | |
| # Add markers for each medical center and add them to a MarkerCluster | |
| marker_cluster = MarkerCluster().add_to(m) | |
| for center in minnesota_med_centers: | |
| folium.Marker( | |
| location=[center[1], center[2]], | |
| popup=f'<b>{center[0]}</b><br>Description: {center[3]}<br>City: {center[4]}', | |
| icon=folium.Icon(color='blue') | |
| ).add_to(marker_cluster) | |
| # Display the map | |
| folium_static(m) | |
| st.markdown(""" | |
| # π₯ Minnesota Medical Centers π³ | |
| The map above shows the location of various medical centers and hospitals in Minnesota. Hover over the markers to learn more about each location. | |
| """) | |
| # Function to update the map when a button is clicked | |
| def update_map(center_data): | |
| m.location = [center_data[1], center_data[2]] | |
| m.zoom_start = 13 | |
| folium_static(m) | |
| # Display buttons to focus on specific medical centers | |
| for i in range(0, len(minnesota_med_centers), 4): | |
| cols = st.columns(4) | |
| for j in range(4): | |
| if i + j < len(minnesota_med_centers): | |
| with cols[j]: | |
| if st.button(minnesota_med_centers[i + j][0]): | |
| update_map(minnesota_med_centers[i + j]) | |