awacke1 commited on
Commit
0aeb981
Β·
1 Parent(s): 8b07209

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -28
app.py CHANGED
@@ -1,6 +1,6 @@
1
  import streamlit as st
2
  import folium
3
- from folium.plugins import MarkerCluster
4
  from streamlit_folium import folium_static
5
  import googlemaps
6
  from datetime import datetime
@@ -32,10 +32,9 @@ def add_medical_center_paths(m, source, med_centers):
32
  _, coords = get_directions_and_coords(source, (lat, lon))
33
  if coords:
34
  folium.PolyLine(coords, color="red", weight=2.5, opacity=1).add_to(m)
35
- folium.Marker([lat, lon], popup=name).add_to(m)
36
  distance_info = gmaps.distance_matrix(source, (lat, lon), mode='driving')
37
  distance = distance_info['rows'][0]['elements'][0]['distance']['text']
38
- folium.PolyLine(coords, color='red').add_to(m)
39
  folium.map.Marker(
40
  [coords[-1][0], coords[-1][1]],
41
  icon=folium.DivIcon(
@@ -46,8 +45,8 @@ def add_medical_center_paths(m, source, med_centers):
46
  ).add_to(m)
47
 
48
  # Streamlit UI
49
- st.title('Google Maps and Minnesota Medical Centers')
50
- st.sidebar.header('Directions')
51
 
52
  source_location = st.sidebar.text_input("Source Location", "Mound, MN")
53
  destination_location = st.sidebar.text_input("Destination Location", "Minneapolis, MN")
@@ -55,44 +54,37 @@ destination_location = st.sidebar.text_input("Destination Location", "Minneapoli
55
  if st.sidebar.button('Get Directions'):
56
  steps, coords = get_directions_and_coords(source_location, destination_location)
57
  if steps and coords:
58
- st.subheader('Driving Directions:')
59
  for i, step in enumerate(steps):
60
  st.write(f"{i+1}. {step['html_instructions']}")
61
- st.subheader('Route on Map:')
62
  m1 = render_folium_map(coords)
63
  folium_static(m1)
64
  else:
65
  st.write("No available routes.")
66
 
67
- # The existing code for Minnesota medical centers
68
  st.markdown("## πŸ₯ Minnesota Medical Centers 🌳")
69
  m2 = folium.Map(location=[45.6945, -93.9002], zoom_start=6)
70
  marker_cluster = MarkerCluster().add_to(m2)
71
 
72
  # Define Minnesota medical centers data
73
  minnesota_med_centers = [
74
- ('Mayo Clinic', 44.0224, -92.4658, 'General medical and surgical', 'Rochester'),
75
- ('University of Minnesota Medical Center', 44.9721, -93.2595, 'Teaching hospital', 'Minneapolis'),
76
- ('Abbott Northwestern Hospital', 44.9526, -93.2622, 'Heart specialty', 'Minneapolis'),
77
- ('Regions Hospital', 44.9558, -93.0942, 'Trauma center', 'St. Paul'),
78
- ('St. Cloud Hospital', 45.5671, -94.1989, 'Multiple specialties', 'St. Cloud'),
79
- ('Park Nicollet Methodist Hospital', 44.9304, -93.3640, 'General medical and surgical', 'St. Louis Park'),
80
- ('Fairview Ridges Hospital', 44.7391, -93.2777, 'Community hospital', 'Burnsville'),
81
- ('Mercy Hospital', 45.1761, -93.3099, 'Acute care', 'Coon Rapids'),
82
- ('North Memorial Health Hospital', 45.0131, -93.3246, 'General medical and surgical', 'Robbinsdale'),
83
- ('Essentia Health-Duluth', 46.7860, -92.1011, 'Community hospital', 'Duluth'),
84
- ('M Health Fairview Southdale Hospital', 44.8806, -93.3241, 'Community hospital', 'Edina'),
85
- ('Woodwinds Health Campus', 44.9272, -92.9689, 'Community hospital', 'Woodbury'),
86
- ('United Hospital', 44.9460, -93.1052, 'Acute care', 'St. Paul'),
87
- ('Buffalo Hospital', 45.1831, -93.8772, 'Community hospital', 'Buffalo'),
88
- ('Maple Grove Hospital', 45.1206, -93.4790, 'Community hospital', 'Maple Grove'),
89
- ('Olmsted Medical Center', 44.0234, -92.4610, 'General medical and surgical', 'Rochester'),
90
- ('Hennepin Healthcare', 44.9738, -93.2605, 'Teaching hospital', 'Minneapolis'),
91
- ('St. Francis Regional Medical Center', 44.7658, -93.5143, 'Community hospital', 'Shakopee'),
92
- ('Lakeview Hospital', 45.0422, -92.8137, 'Community hospital', 'Stillwater'),
93
- ('St. Luke\'s Hospital', 46.7831, -92.1043, 'Community hospital', 'Duluth')
94
  ]
95
 
96
  # Annotate distances and paths for each medical center
97
  add_medical_center_paths(m2, source_location, minnesota_med_centers)
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  folium_static(m2)
 
1
  import streamlit as st
2
  import folium
3
+ from folium.plugins import MarkerCluster, Search
4
  from streamlit_folium import folium_static
5
  import googlemaps
6
  from datetime import datetime
 
32
  _, coords = get_directions_and_coords(source, (lat, lon))
33
  if coords:
34
  folium.PolyLine(coords, color="red", weight=2.5, opacity=1).add_to(m)
35
+ folium.Marker([lat, lon], popup=name, icon=folium.Icon(color="red")).add_to(m)
36
  distance_info = gmaps.distance_matrix(source, (lat, lon), mode='driving')
37
  distance = distance_info['rows'][0]['elements'][0]['distance']['text']
 
38
  folium.map.Marker(
39
  [coords[-1][0], coords[-1][1]],
40
  icon=folium.DivIcon(
 
45
  ).add_to(m)
46
 
47
  # Streamlit UI
48
+ st.title('Google Maps and Minnesota Medical Centers πŸ—ΊοΈ')
49
+ st.sidebar.header('Directions πŸš—')
50
 
51
  source_location = st.sidebar.text_input("Source Location", "Mound, MN")
52
  destination_location = st.sidebar.text_input("Destination Location", "Minneapolis, MN")
 
54
  if st.sidebar.button('Get Directions'):
55
  steps, coords = get_directions_and_coords(source_location, destination_location)
56
  if steps and coords:
57
+ st.subheader('Driving Directions: πŸ›£οΈ')
58
  for i, step in enumerate(steps):
59
  st.write(f"{i+1}. {step['html_instructions']}")
60
+ st.subheader('Route on Map: 🌐')
61
  m1 = render_folium_map(coords)
62
  folium_static(m1)
63
  else:
64
  st.write("No available routes.")
65
 
 
66
  st.markdown("## πŸ₯ Minnesota Medical Centers 🌳")
67
  m2 = folium.Map(location=[45.6945, -93.9002], zoom_start=6)
68
  marker_cluster = MarkerCluster().add_to(m2)
69
 
70
  # Define Minnesota medical centers data
71
  minnesota_med_centers = [
72
+ # ... (your existing medical centers)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
73
  ]
74
 
75
  # Annotate distances and paths for each medical center
76
  add_medical_center_paths(m2, source_location, minnesota_med_centers)
77
+
78
+ # Adding a Search bar to the map
79
+ geolocator = Nominatim(user_agent="geoapiExercises")
80
+ search = Search(layer=marker_cluster, geom_type='Point').add_to(m2)
81
+
82
+ # Add a layer control
83
+ folium.LayerControl().add_to(m2)
84
+
85
+ # Points of Interest around medical centers
86
+ for name, lat, lon, specialty, city in minnesota_med_centers:
87
+ folium.Marker([lat+0.01, lon], icon=folium.Icon(color="blue", icon="cloud"), popup="Park").add_to(m2)
88
+ folium.Marker([lat-0.01, lon], icon=folium.Icon(color="green", icon="leaf"), popup="Cafe").add_to(m2)
89
+
90
  folium_static(m2)