Get User Location Button

Hey all!

I have been trying to get the user’s location for an app that I want to deploy to the cloud. I realized that the user’s IP address is not really easily available when your app is being served from a cloud server. So I built this little component that returns the javascript navigator.geolocation.getCurrentPosition().coords method/object when pressed. I’d love if people checked it out and critiqued it. I come from Python land, so the react side was a big struggle! Please give me feedback!

Install it with

pip install streamlit-geolocation

To use it in a streamlit app:

from streamlit_geolocation import streamlit_geolocation
location = streamlit_geolocation()
print(location)
outputs: {'latitude': 35.9700706, 'longitude': -83.9184362, 'altitude': None, 'accuracy': 12.684, 'altitudeAccuracy': None, 'heading': None, 'speed': None}

ezgif-3-db15f9fb71

Thanks for checking it out!

4 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.