MayankGupta06 commited on
Commit
37bca9a
Β·
verified Β·
1 Parent(s): e9a9125

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -39
app.py CHANGED
@@ -590,48 +590,22 @@ elif option == "Symptom Checker":
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())
614
- lon = float(parts[1].strip())
615
- else:
616
- location = geolocator.geocode(manual_input)
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
 
 
590
  elif option == "Doctor Connect":
591
  st.subheader("πŸ₯ Find a Doctor Near You")
592
 
593
+ address = st.text_input("Enter your location (City, State or full address):")
594
+
595
+ if address:
596
+ geolocator = Nominatim(user_agent="geoapi")
597
+ location = geolocator.geocode(address)
598
+ if location:
599
+ lat, lon = location.latitude, location.longitude
600
+ st.success(f"πŸ“ Location found: {lat:.4f}, {lon:.4f}")
601
+ map_ = folium.Map(location=[lat, lon], zoom_start=13)
602
+ folium.Marker([lat, lon], popup="You are here!", icon=folium.Icon(color="blue")).add_to(map_)
603
+ folium_static(map_)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
604
  else:
605
+ st.error("❌ Could not find location. Please try a more specific address.")
606
  else:
607
+ st.info("πŸ” Please enter your location above to proceed.")
608
 
 
 
 
 
 
609
 
610
 
611