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()
outputs: {'latitude': 35.9700706, 'longitude': -83.9184362, 'altitude': None, 'accuracy': 12.684, 'altitudeAccuracy': None, 'heading': None, 'speed': None}


Thanks for checking it out!


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