ybendou commited on
Commit
a067809
·
1 Parent(s): bbbef88

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -1
app.py CHANGED
@@ -203,7 +203,33 @@ df = parse_gg_sheet(REQUESTS_URL)
203
  df = add_latlng_col(df, process_column=15)
204
  interventions_df = parse_gg_sheet(INTERVENTIONS_URL)
205
  interventions_df = add_latlng_col(interventions_df, process_column=12)
206
- m = init_map()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
  # Selection of requests
209
  options = [
 
203
  df = add_latlng_col(df, process_column=15)
204
  interventions_df = parse_gg_sheet(INTERVENTIONS_URL)
205
  interventions_df = add_latlng_col(interventions_df, process_column=12)
206
+
207
+ # Get current location:
208
+
209
+ js_code = """
210
+ function getLocation() {
211
+ navigator.geolocation.getCurrentPosition(function (position) {
212
+ document.getElementById("localisation").value = JSON.stringify({
213
+ latitude: position.coords.latitude,
214
+ longitude: position.coords.longitude
215
+ });
216
+ document.getElementById("localisation").dispatchEvent(new Event('input', { 'bubbles': true }));
217
+ }, function () {
218
+ document.getElementById("localisation").value = JSON.stringify({
219
+ latitude: null,
220
+ longitude: null
221
+ });
222
+ document.getElementById("localisation").dispatchEvent(new Event('input', { 'bubbles': true }));
223
+ });
224
+ }
225
+ getLocation();
226
+ """
227
+ st.markdown(f"<script>{js_code}</script>", unsafe_allow_html=True)
228
+
229
+ # Hidden field to store the JavaScript variable
230
+ current_localisation = st.text_input("localisation", "", key="localisation", type="hidden")
231
+
232
+ m = init_map(current_localisation=current_localisation)
233
 
234
  # Selection of requests
235
  options = [