ybendou commited on
Commit
01ec6c5
·
1 Parent(s): f65f31e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -211,11 +211,13 @@ from streamlit_bokeh_events import streamlit_bokeh_events
211
 
212
  loc_button = Button(label="Get Location")
213
  loc_button.js_on_event("button_click", CustomJS(code="""
214
- navigator.geolocation.getCurrentPosition(
215
- (loc) => {
216
- document.dispatchEvent(new CustomEvent("GET_LOCATION", {detail: {lat: loc.coords.latitude, lon: loc.coords.longitude}}))
217
- }
218
- )
 
 
219
  """))
220
  current_localisation = streamlit_bokeh_events(
221
  loc_button,
 
211
 
212
  loc_button = Button(label="Get Location")
213
  loc_button.js_on_event("button_click", CustomJS(code="""
214
+ navigator.geolocation.getCurrentPosition(function (position) {
215
+ localStorage.setItem('localisation', JSON.stringify({latitude: position.coords.latitude, longitude: position.coords.longitude}))
216
+
217
+ }, function () {
218
+ localStorage.setItem('localisation', JSON.stringify({latitude: null, longitude: null}))
219
+
220
+ });
221
  """))
222
  current_localisation = streamlit_bokeh_events(
223
  loc_button,