Spaces:
Sleeping
Sleeping
search functionality added
Browse files- pag/add_field.py +3 -7
pag/add_field.py
CHANGED
@@ -8,9 +8,8 @@ from folium.plugins import Draw
|
|
8 |
from shapely.geometry import Polygon
|
9 |
from streamlit_folium import st_folium
|
10 |
from authentication import greeting, check_password
|
11 |
-
# import shapely.ops as ops
|
12 |
from functools import partial
|
13 |
-
|
14 |
from pyproj import Transformer
|
15 |
from shapely.ops import transform
|
16 |
from geopy.geocoders import Nominatim
|
@@ -60,12 +59,9 @@ def add_existing_fields_to_map(field_map, current_user):
|
|
60 |
def get_center_of_existing_fields(current_user):
|
61 |
location_name = st.text_input('Enter a location to search:')
|
62 |
if location_name:
|
63 |
-
|
|
|
64 |
if lat is not None and lon is not None:
|
65 |
-
# Update your map to center on the search result and adjust zoom as desired
|
66 |
-
m = folium.Map(location=[lat, lon], zoom_start=13)
|
67 |
-
# Add the map to the Streamlit app
|
68 |
-
# st_data = folium_static(m)
|
69 |
return [lat, lon]
|
70 |
else:
|
71 |
st.error('Location not found. Please try again.')
|
|
|
8 |
from shapely.geometry import Polygon
|
9 |
from streamlit_folium import st_folium
|
10 |
from authentication import greeting, check_password
|
|
|
11 |
from functools import partial
|
12 |
+
import geopy
|
13 |
from pyproj import Transformer
|
14 |
from shapely.ops import transform
|
15 |
from geopy.geocoders import Nominatim
|
|
|
59 |
def get_center_of_existing_fields(current_user):
|
60 |
location_name = st.text_input('Enter a location to search:')
|
61 |
if location_name:
|
62 |
+
geolocator = Nominatim(user_agent="geoapiExercises")
|
63 |
+
lat, lon = get_location_coordinates(location_name,geolocator)
|
64 |
if lat is not None and lon is not None:
|
|
|
|
|
|
|
|
|
65 |
return [lat, lon]
|
66 |
else:
|
67 |
st.error('Location not found. Please try again.')
|