Update backupapp.py
Browse files- backupapp.py +23 -0
backupapp.py
CHANGED
@@ -27,6 +27,25 @@ def render_folium_map(coords):
|
|
27 |
folium.PolyLine(coords, color="blue", weight=2.5, opacity=1).add_to(m)
|
28 |
return m
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
# Streamlit UI
|
31 |
st.title('Google Maps and Minnesota Medical Centers')
|
32 |
st.sidebar.header('Directions')
|
@@ -50,6 +69,7 @@ if st.sidebar.button('Get Directions'):
|
|
50 |
st.markdown("## π₯ Minnesota Medical Centers π³")
|
51 |
m2 = folium.Map(location=[45.6945, -93.9002], zoom_start=6)
|
52 |
marker_cluster = MarkerCluster().add_to(m2)
|
|
|
53 |
# Define Minnesota medical centers data
|
54 |
minnesota_med_centers = [
|
55 |
('Mayo Clinic', 44.0224, -92.4658, 'General medical and surgical', 'Rochester'),
|
@@ -73,4 +93,7 @@ minnesota_med_centers = [
|
|
73 |
('Lakeview Hospital', 45.0422, -92.8137, 'Community hospital', 'Stillwater'),
|
74 |
('St. Luke\'s Hospital', 46.7831, -92.1043, 'Community hospital', 'Duluth')
|
75 |
]
|
|
|
|
|
|
|
76 |
folium_static(m2)
|
|
|
27 |
folium.PolyLine(coords, color="blue", weight=2.5, opacity=1).add_to(m)
|
28 |
return m
|
29 |
|
30 |
+
# Function to add medical center paths and annotate distance
|
31 |
+
def add_medical_center_paths(m, source, med_centers):
|
32 |
+
for name, lat, lon, specialty, city in med_centers:
|
33 |
+
_, coords = get_directions_and_coords(source, (lat, lon))
|
34 |
+
if coords:
|
35 |
+
folium.PolyLine(coords, color="red", weight=2.5, opacity=1).add_to(m)
|
36 |
+
folium.Marker([lat, lon], popup=name).add_to(m)
|
37 |
+
distance_info = gmaps.distance_matrix(source, (lat, lon), mode='driving')
|
38 |
+
distance = distance_info['rows'][0]['elements'][0]['distance']['text']
|
39 |
+
folium.PolyLine(coords, color='red').add_to(m)
|
40 |
+
folium.map.Marker(
|
41 |
+
[coords[-1][0], coords[-1][1]],
|
42 |
+
icon=folium.DivIcon(
|
43 |
+
icon_size=(150, 36),
|
44 |
+
icon_anchor=(0, 0),
|
45 |
+
html=f'<div style="font-size: 10pt; color : red;">{distance}</div>',
|
46 |
+
)
|
47 |
+
).add_to(m)
|
48 |
+
|
49 |
# Streamlit UI
|
50 |
st.title('Google Maps and Minnesota Medical Centers')
|
51 |
st.sidebar.header('Directions')
|
|
|
69 |
st.markdown("## π₯ Minnesota Medical Centers π³")
|
70 |
m2 = folium.Map(location=[45.6945, -93.9002], zoom_start=6)
|
71 |
marker_cluster = MarkerCluster().add_to(m2)
|
72 |
+
|
73 |
# Define Minnesota medical centers data
|
74 |
minnesota_med_centers = [
|
75 |
('Mayo Clinic', 44.0224, -92.4658, 'General medical and surgical', 'Rochester'),
|
|
|
93 |
('Lakeview Hospital', 45.0422, -92.8137, 'Community hospital', 'Stillwater'),
|
94 |
('St. Luke\'s Hospital', 46.7831, -92.1043, 'Community hospital', 'Duluth')
|
95 |
]
|
96 |
+
|
97 |
+
# Annotate distances and paths for each medical center
|
98 |
+
add_medical_center_paths(m2, source_location, minnesota_med_centers)
|
99 |
folium_static(m2)
|