File size: 1,786 Bytes
782e635
 
 
312f467
782e635
 
 
 
 
 
 
65d4dac
 
312f467
 
65d4dac
782e635
 
 
 
 
 
 
 
312f467
 
 
 
 
 
 
 
 
 
 
782e635
65d4dac
782e635
65d4dac
782e635
 
 
 
 
 
 
 
 
 
 
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
"""
Hospital Map Component for DermaScan AI
"""
import os
import streamlit as st


def render_hospital_map(result, selected_city, selected_state):
    hosp_type = result.get("hospital_type", "Dermatologist")
    location = result.get("hospital_location", f"{selected_city}, {selected_state}")

    search_query = result.get("hospital_search_query", "dermatologist near me")
    full_query = f"{search_query} in {selected_city}, {selected_state}, India"
    encoded_query = full_query.replace(" ", "+")
    maps_url = "https://www.google.com/maps/search/" + encoded_query

    st.markdown(
        f'<div class="pro-card">'
        f"<h3>πŸ₯ Find {hosp_type}</h3>"
        f"<p>πŸ“ Searching in: <strong>{location}</strong></p>"
        f"</div>",
        unsafe_allow_html=True,
    )

    api_key = os.environ.get("MAPS_API_KEY", "")
    if api_key:
        embed_url = f"https://www.google.com/maps/embed/v1/search?key={api_key}&q={encoded_query}"
        st.markdown(
            f'<iframe width="100%" height="450" style="border:0;border-radius:12px;" '
            f'src="{embed_url}" allowfullscreen loading="lazy"></iframe>',
            unsafe_allow_html=True,
        )
    else:
        st.info("Set the MAPS_API_KEY secret in HF Space settings to enable the embedded map.")

    st.link_button(
        f"πŸ—ΊοΈ Open Google Maps β€” {hosp_type}",
        maps_url,
        use_container_width=True,
    )

    st.markdown("")

    emergency = result.get("emergency_numbers", {})
    if emergency:
        emer_html = '<div class="emergency-card"><h4>🚨 Emergency Contacts</h4>'
        for label, num in emergency.items():
            emer_html += f"<p>πŸ“ž {label}: <b>{num}</b></p>"
        emer_html += "</div>"
        st.markdown(emer_html, unsafe_allow_html=True)