Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -207,24 +207,24 @@ interventions_df = add_latlng_col(interventions_df, process_column=12)
|
|
207 |
# Get current location:
|
208 |
|
209 |
js_code = """
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
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 |
-
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
|
229 |
# Hidden field to store the JavaScript variable
|
230 |
current_localisation = st.text_input("localisation", "", key="localisation", type="hidden")
|
|
|
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")
|