JulsdL commited on
Commit
2b3a5ca
·
1 Parent(s): c669520

Refactor map rendering to use an empty container for better management and add latitude/longitude input fields

Browse files
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -53,14 +53,18 @@ def main():
53
  st.error(f"Error fetching location data: {str(e)}")
54
  else:
55
  st.write("Select your location on the map:")
56
- default_location = [37.7749, -122.4194]
57
- map_display = folium.Map(location=default_location, zoom_start=2)
58
- folium.Marker(default_location, tooltip="Default Location").add_to(map_display)
59
- map_data = st_folium(map_display, width=350, height=300)
60
- if map_data and 'last_clicked' in map_data and map_data['last_clicked']:
61
- latitude = map_data['last_clicked']['lat']
62
- longitude = map_data['last_clicked']['lng']
 
 
 
63
 
 
64
  latitude = st.text_input("Latitude:", value=str(latitude) if 'latitude' in locals() else "")
65
  longitude = st.text_input("Longitude:", value=str(longitude) if 'longitude' in locals() else "")
66
 
 
53
  st.error(f"Error fetching location data: {str(e)}")
54
  else:
55
  st.write("Select your location on the map:")
56
+ # Use an empty container to manage the map rendering
57
+ map_placeholder = st.empty()
58
+ with map_placeholder:
59
+ default_location = [37.7749, -122.4194]
60
+ map_display = folium.Map(location=default_location, zoom_start=2)
61
+ folium.Marker(default_location, tooltip="Default Location").add_to(map_display)
62
+ map_data = st_folium(map_display, width=350, height=300)
63
+ if map_data and 'last_clicked' in map_data and map_data['last_clicked']:
64
+ latitude = map_data['last_clicked']['lat']
65
+ longitude = map_data['last_clicked']['lng']
66
 
67
+ # Latitude and Longitude input fields
68
  latitude = st.text_input("Latitude:", value=str(latitude) if 'latitude' in locals() else "")
69
  longitude = st.text_input("Longitude:", value=str(longitude) if 'longitude' in locals() else "")
70