Update app.py
Browse files
app.py
CHANGED
@@ -589,31 +589,25 @@ elif option == "Symptom Checker":
|
|
589 |
|
590 |
elif option == "Doctor Connect":
|
591 |
st.subheader("π₯ Find a Doctor Near You")
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
location_choice = st.radio("How would you like to set your location?", ("Use My Location", "Enter Manually"))
|
603 |
-
|
604 |
-
lat, lon = None, None
|
605 |
-
|
606 |
-
if location_choice == "Use My Location":
|
607 |
-
lat, lon = get_browser_location()
|
608 |
-
if lat and lon:
|
609 |
-
st.success(f"π Location detected: {lat:.4f}, {lon:.4f}")
|
610 |
-
else:
|
611 |
-
st.warning("β οΈ Could not detect your location. Please enter it manually.")
|
612 |
else:
|
613 |
-
|
|
|
|
|
|
|
|
|
614 |
if manual_input:
|
615 |
geolocator = Nominatim(user_agent="geoapi")
|
616 |
try:
|
|
|
617 |
if "," in manual_input:
|
618 |
parts = manual_input.split(",")
|
619 |
lat = float(parts[0].strip())
|
@@ -623,19 +617,25 @@ elif option == "Doctor Connect":
|
|
623 |
if location:
|
624 |
lat, lon = location.latitude, location.longitude
|
625 |
else:
|
626 |
-
st.error("β
|
|
|
627 |
except:
|
628 |
-
st.error("
|
629 |
-
|
630 |
-
|
|
|
|
|
|
|
|
|
631 |
if lat and lon:
|
|
|
632 |
map_ = folium.Map(location=[lat, lon], zoom_start=13)
|
633 |
folium.Marker([lat, lon], popup="You are here!", icon=folium.Icon(color="blue")).add_to(map_)
|
634 |
-
st.write("π Your Location on Map:")
|
635 |
folium_static(map_)
|
636 |
|
637 |
|
638 |
|
|
|
639 |
# elif option == "Doctor Connect":
|
640 |
# st.subheader("π Doctor Connect - Find Nearby Hospitals")
|
641 |
|
|
|
589 |
|
590 |
elif option == "Doctor Connect":
|
591 |
st.subheader("π₯ Find a Doctor Near You")
|
592 |
+
|
593 |
+
st.markdown("**πΉ We'll try to detect your location automatically. You can also enter it manually if needed.**")
|
594 |
+
|
595 |
+
auto_lat, auto_lon = get_user_location()
|
596 |
+
use_manual = False
|
597 |
+
|
598 |
+
if auto_lat and auto_lon:
|
599 |
+
st.success(f"π Auto-detected Location: Latitude {auto_lat}, Longitude {auto_lon}")
|
600 |
+
use_manual = st.checkbox("Is this incorrect? Click here to enter location manually.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
else:
|
602 |
+
st.warning("β οΈ Could not auto-detect your location.")
|
603 |
+
use_manual = True
|
604 |
+
|
605 |
+
if use_manual:
|
606 |
+
manual_input = st.text_input("Enter your location (City, State or Latitude, Longitude):")
|
607 |
if manual_input:
|
608 |
geolocator = Nominatim(user_agent="geoapi")
|
609 |
try:
|
610 |
+
# Handle input as coordinates if comma is found
|
611 |
if "," in manual_input:
|
612 |
parts = manual_input.split(",")
|
613 |
lat = float(parts[0].strip())
|
|
|
617 |
if location:
|
618 |
lat, lon = location.latitude, location.longitude
|
619 |
else:
|
620 |
+
st.error("β Invalid location entered.")
|
621 |
+
lat, lon = None, None
|
622 |
except:
|
623 |
+
st.error("β Error parsing location input.")
|
624 |
+
lat, lon = None, None
|
625 |
+
else:
|
626 |
+
lat, lon = None, None
|
627 |
+
else:
|
628 |
+
lat, lon = auto_lat, auto_lon
|
629 |
+
|
630 |
if lat and lon:
|
631 |
+
st.success(f"π Final Location: Latitude {lat}, Longitude {lon}")
|
632 |
map_ = folium.Map(location=[lat, lon], zoom_start=13)
|
633 |
folium.Marker([lat, lon], popup="You are here!", icon=folium.Icon(color="blue")).add_to(map_)
|
|
|
634 |
folium_static(map_)
|
635 |
|
636 |
|
637 |
|
638 |
+
|
639 |
# elif option == "Doctor Connect":
|
640 |
# st.subheader("π Doctor Connect - Find Nearby Hospitals")
|
641 |
|