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
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.