ybendou commited on
Commit
1c72862
1 Parent(s): bf06aef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -7
app.py CHANGED
@@ -211,13 +211,11 @@ 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(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_location = streamlit_bokeh_events(
223
  loc_button,
 
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_location = streamlit_bokeh_events(
221
  loc_button,