Meet Radadiya commited on
Commit
312f467
Β·
1 Parent(s): 65d4dac

Use MAPS_API_KEY env secret for Google Maps embed

Browse files
Files changed (1) hide show
  1. frontend/components/hospital_map.py +24 -2
frontend/components/hospital_map.py CHANGED
@@ -1,6 +1,7 @@
1
  """
2
  Hospital Map Component for DermaScan AI
3
  """
 
4
  import streamlit as st
5
 
6
 
@@ -10,17 +11,28 @@ def render_hospital_map(result, selected_city, selected_state):
10
 
11
  search_query = result.get("hospital_search_query", "dermatologist near me")
12
  full_query = f"{search_query} in {selected_city}, {selected_state}, India"
13
- maps_url = "https://www.google.com/maps/search/" + full_query.replace(" ", "+")
 
14
 
15
  st.markdown(
16
  f'<div class="pro-card">'
17
  f"<h3>πŸ₯ Find {hosp_type}</h3>"
18
  f"<p>πŸ“ Searching in: <strong>{location}</strong></p>"
19
- f'<p style="color:#94a3b8;font-size:0.9rem;">Click the button below to find nearby specialists on Google Maps.</p>'
20
  f"</div>",
21
  unsafe_allow_html=True,
22
  )
23
 
 
 
 
 
 
 
 
 
 
 
 
24
  st.link_button(
25
  f"πŸ—ΊοΈ Open Google Maps β€” {hosp_type}",
26
  maps_url,
@@ -36,3 +48,13 @@ def render_hospital_map(result, selected_city, selected_state):
36
  emer_html += f"<p>πŸ“ž {label}: <b>{num}</b></p>"
37
  emer_html += "</div>"
38
  st.markdown(emer_html, unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
1
  """
2
  Hospital Map Component for DermaScan AI
3
  """
4
+ import os
5
  import streamlit as st
6
 
7
 
 
11
 
12
  search_query = result.get("hospital_search_query", "dermatologist near me")
13
  full_query = f"{search_query} in {selected_city}, {selected_state}, India"
14
+ encoded_query = full_query.replace(" ", "+")
15
+ maps_url = "https://www.google.com/maps/search/" + encoded_query
16
 
17
  st.markdown(
18
  f'<div class="pro-card">'
19
  f"<h3>πŸ₯ Find {hosp_type}</h3>"
20
  f"<p>πŸ“ Searching in: <strong>{location}</strong></p>"
 
21
  f"</div>",
22
  unsafe_allow_html=True,
23
  )
24
 
25
+ api_key = os.environ.get("MAPS_API_KEY", "")
26
+ if api_key:
27
+ embed_url = f"https://www.google.com/maps/embed/v1/search?key={api_key}&q={encoded_query}"
28
+ st.markdown(
29
+ f'<iframe width="100%" height="450" style="border:0;border-radius:12px;" '
30
+ f'src="{embed_url}" allowfullscreen loading="lazy"></iframe>',
31
+ unsafe_allow_html=True,
32
+ )
33
+ else:
34
+ st.info("Set the MAPS_API_KEY secret in HF Space settings to enable the embedded map.")
35
+
36
  st.link_button(
37
  f"πŸ—ΊοΈ Open Google Maps β€” {hosp_type}",
38
  maps_url,
 
48
  emer_html += f"<p>πŸ“ž {label}: <b>{num}</b></p>"
49
  emer_html += "</div>"
50
  st.markdown(emer_html, unsafe_allow_html=True)
51
+
52
+ st.markdown("")
53
+
54
+ emergency = result.get("emergency_numbers", {})
55
+ if emergency:
56
+ emer_html = '<div class="emergency-card"><h4>🚨 Emergency Contacts</h4>'
57
+ for label, num in emergency.items():
58
+ emer_html += f"<p>πŸ“ž {label}: <b>{num}</b></p>"
59
+ emer_html += "</div>"
60
+ st.markdown(emer_html, unsafe_allow_html=True)