Spaces:
Sleeping
Sleeping
| """ | |
| 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) | |