semvec/pypi-packages huggingface dataset:
streamlit-geolocation 0.0.10
A custom Streamlit component to get the users location via js navigator.geolocation.
Requires Python: >=3.8
Keywords: Python,Streamlit,JavaScript

# streamlit-geolocation
A geolocation button for streamlit

### Installation
`pip install streamlit-geolocation`

### Usage
`from streamlit_geolocation import streamlit_geolocation`

`location = streamlit_geolocation()`

`st.write(location)`

`outputs: {'latitude': 35.9700706, 'longitude': -83.9184362, 'altitude': None, 'accuracy': 12.684, 'altitudeAccuracy': None, 'heading': None, 'speed': None}`

Of course, at first it will output "No Location Info" until you press the button. 

This uses the javascript method navigator.geolocation.getCurrentPosition to get the user's location. The response is a GeolocationCoordinates object.

This is heavily inspired by this repository: https://github.com/aghasemi/streamlit_js_eval 
I am simplifying the scope to just getting the user's location and not evaluating arbitrary javascript, but I owe a lot to the original author.

![sample](sample.gif)