Hi,
Is there a way to use, or a plan to implement the web Geolocation API for asking the user’s location and continue processing based on that?
Thanks
Hi,
Is there a way to use, or a plan to implement the web Geolocation API for asking the user’s location and continue processing based on that?
Thanks
Hey @aghasemi ,
Yep, just use streamlit-bokeh-events with this bunch of code and it works pretty well 
PS. you can execute any custom js this way on a event and get the value in the callback without writting a full component 
Hope it helps !
That really deserves more publicity!
And many thanks.
Hello!
This code is working but the location I am getting is not my current location, but my wifi service’s.
Please help
Thankyou
Thanks for providing this nice solution. I noticed that if the web app is embedded (“iframe”) in an HTML, the get location button is not responding. See the examples below.
Working: https://share.streamlit.io/giswqs/streamlit-geospatial/app.py?page=Create+Timelapse
Not working: https://streamlit.gishub.org
HMTL: streamlit-geospatial/index.html at gh-pages · giswqs/streamlit-geospatial · GitHub
@ash2shukla , thanks for the idea.
I’ve tried it out locally, it works well on my laptop but my mobile device isn’t reacting to the button click (I can see the page with the button, but clicking on it doesn’t seem to do anything).
Any ideas what I’m doing wrong or what I need to do to get it to work on an Android device?
For others who may pass by here, I wrote an alternative, maybe less verbose and more lightweight solution which can be used to not only ask for user’s location, but also call virtually any JavaScript/Web API from Streamlit and get the result. Here it is: GitHub - aghasemi/streamlit_js_eval: A custom Streamlit component to evaluate arbitrary Javascript expressions
Feedback is very much appreciated.
Hi! I wanted to express my gratitude for providing such a useful component. It’s exactly what I was looking for. However, I’d like to offer some feedback. In your example, it’s not very clear how to use the get_geolocation method. It seems to suggest that it returns the coordinates directly (latitude and longitude), but in reality, it returns JSON data. To retrieve the coordinates, one needs to navigate through the JSON structure, accessing “coords” and then “latitude” and “longitude” fields. This discrepancy between the example and the actual method behavior could be clarified. Providing a more detailed example demonstrating the usage of this method would be greatly appreciated. Nonetheless, I find your component awesome! Thank you so much for creating it!
Hi. Thanks a lot for your interest.
If you look at MDN documents for the GeoLocation API, that explains what data the API provides. I wanted to return all that information, not just the latitude/longitude (i.e. the coords object).
thank you I used yours ![]()