pjgerrits commited on
Commit
b761ce2
1 Parent(s): 768c765

update zoom refresh

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -119,13 +119,13 @@ map_placeholder = st.empty()
119
 
120
  with map_placeholder.container():
121
  folium_map = create_map(st.session_state['points'], center=st.session_state['map_center'], zoom=st.session_state['map_zoom'])
122
- map_output = st_folium(folium_map, width="100%", height=800)
123
 
124
  new_coords = None
125
  if map_output and 'last_clicked' in map_output and map_output['last_clicked'] is not None:
126
  new_coords = (map_output['last_clicked']['lat'], map_output['last_clicked']['lng'])
127
- # Update the map center to the last clicked location
128
- st.session_state['map_center'] = [map_output['last_clicked']['lat'], map_output['last_clicked']['lng']]
129
  st.session_state['map_zoom'] = map_output['zoom']
130
 
131
  if new_coords:
@@ -133,7 +133,7 @@ if new_coords:
133
  map_placeholder.empty()
134
  with map_placeholder.container():
135
  folium_map = create_map(st.session_state['points'], center=st.session_state['map_center'], zoom=st.session_state['map_zoom'])
136
- st_folium(folium_map, width="100%", height=800)
137
 
138
  if all(st.session_state['points'].values()) and not st.session_state['survey']:
139
  if st.sidebar.button("Proceed to Survey"):
 
119
 
120
  with map_placeholder.container():
121
  folium_map = create_map(st.session_state['points'], center=st.session_state['map_center'], zoom=st.session_state['map_zoom'])
122
+ map_output = st_folium(folium_map, width="100%", height=500)
123
 
124
  new_coords = None
125
  if map_output and 'last_clicked' in map_output and map_output['last_clicked'] is not None:
126
  new_coords = (map_output['last_clicked']['lat'], map_output['last_clicked']['lng'])
127
+ # Update the map center to the current view, ensuring it's a list
128
+ st.session_state['map_center'] = [map_output['center']['lat'], map_output['center']['lng']]
129
  st.session_state['map_zoom'] = map_output['zoom']
130
 
131
  if new_coords:
 
133
  map_placeholder.empty()
134
  with map_placeholder.container():
135
  folium_map = create_map(st.session_state['points'], center=st.session_state['map_center'], zoom=st.session_state['map_zoom'])
136
+ st_folium(folium_map, width="100%", height=500)
137
 
138
  if all(st.session_state['points'].values()) and not st.session_state['survey']:
139
  if st.sidebar.button("Proceed to Survey"):