Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -205,33 +205,25 @@ 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 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
navigator.geolocation.getCurrentPosition(
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
}
|
228 |
-
getLocation();
|
229 |
-
console.log(localisation);
|
230 |
-
"""
|
231 |
-
st.markdown(f"<script>{js_code}</script>", unsafe_allow_html=True)
|
232 |
-
|
233 |
-
# Hidden field to store the JavaScript variable
|
234 |
-
current_localisation = st.text_input("localisation", "", key="localisation", label_visibility="hidden")
|
235 |
|
236 |
m = init_map(current_localisation=current_localisation)
|
237 |
|
|
|
205 |
interventions_df = add_latlng_col(interventions_df, process_column=12)
|
206 |
|
207 |
# Get current location:
|
208 |
+
from bokeh.models.widgets import Button
|
209 |
+
from bokeh.models import CustomJS
|
210 |
+
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,
|
222 |
+
events="GET_LOCATION",
|
223 |
+
key="get_location",
|
224 |
+
refresh_on_update=False,
|
225 |
+
override_height=75,
|
226 |
+
debounce_time=0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
|
228 |
m = init_map(current_localisation=current_localisation)
|
229 |
|