Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,8 +39,8 @@ with gr.Blocks() as demo:
|
|
| 39 |
|
| 40 |
qr_image = gr.Image(type="pil", label="Upload QR Code Image")
|
| 41 |
|
| 42 |
-
lat_input = gr.Textbox(label="Latitude", interactive=False)
|
| 43 |
-
lng_input = gr.Textbox(label="Longitude", interactive=False)
|
| 44 |
output = gr.Textbox(label="Result")
|
| 45 |
|
| 46 |
btn = gr.Button("Scan & Submit")
|
|
@@ -52,16 +52,17 @@ with gr.Blocks() as demo:
|
|
| 52 |
|
| 53 |
# แทรก JS ผ่าน HTML component
|
| 54 |
gr.HTML("""
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
""")
|
| 66 |
|
|
|
|
| 67 |
demo.launch()
|
|
|
|
| 39 |
|
| 40 |
qr_image = gr.Image(type="pil", label="Upload QR Code Image")
|
| 41 |
|
| 42 |
+
lat_input = gr.Textbox(label="Latitude", interactive=True, visible=False)
|
| 43 |
+
lng_input = gr.Textbox(label="Longitude", interactive=True, visible=False)
|
| 44 |
output = gr.Textbox(label="Result")
|
| 45 |
|
| 46 |
btn = gr.Button("Scan & Submit")
|
|
|
|
| 52 |
|
| 53 |
# แทรก JS ผ่าน HTML component
|
| 54 |
gr.HTML("""
|
| 55 |
+
<script>
|
| 56 |
+
if (navigator.geolocation) {
|
| 57 |
+
navigator.geolocation.getCurrentPosition(function(position) {
|
| 58 |
+
document.querySelectorAll('textarea[name="Latitude"]')[0].value = position.coords.latitude;
|
| 59 |
+
document.querySelectorAll('textarea[name="Longitude"]')[0].value = position.coords.longitude;
|
| 60 |
+
});
|
| 61 |
+
} else {
|
| 62 |
+
alert("Geolocation is not supported by this browser.");
|
| 63 |
+
}
|
| 64 |
+
</script>
|
| 65 |
""")
|
| 66 |
|
| 67 |
+
|
| 68 |
demo.launch()
|