# 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)
Raw data
{
"_id": null,
"home_page": "https://github.com/steffanic/streamlit-geolocation",
"name": "streamlit-geolocation",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "Python,Streamlit,JavaScript",
"author": "Patrick Steffanic",
"author_email": "steffaniccodes@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/86/e2/f3d7da8d0e9892a5f20e53603b08a71cdb98a813193213b2cbcc3bb0e5f3/streamlit_geolocation-0.0.10.tar.gz",
"platform": null,
"description": "# streamlit-geolocation\nA geolocation button for streamlit\n\n### Installation\n`pip install streamlit-geolocation`\n\n### Usage\n`from streamlit_geolocation import streamlit_geolocation`\n\n`location = streamlit_geolocation()`\n\n`st.write(location)`\n\n`outputs: {'latitude': 35.9700706, 'longitude': -83.9184362, 'altitude': None, 'accuracy': 12.684, 'altitudeAccuracy': None, 'heading': None, 'speed': None}`\n\nOf course, at first it will output \"No Location Info\" until you press the button. \n\nThis uses the javascript method navigator.geolocation.getCurrentPosition to get the user's location. The response is a GeolocationCoordinates object.\n\nThis is heavily inspired by this repository: https://github.com/aghasemi/streamlit_js_eval \nI 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.\n\n![sample](sample.gif)\n",
"bugtrack_url": null,
"license": "",
"summary": "A custom Streamlit component to get the users location via js navigator.geolocation.",
"version": "0.0.10",
"project_urls": {
"Homepage": "https://github.com/steffanic/streamlit-geolocation"
},
"split_keywords": [
"python",
"streamlit",
"javascript"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2b64619d0332c50ecb65a5c03c63e78c06855325c8f605459168aa96a06ce042",
"md5": "f52612594afce165f712d55e6870476a",
"sha256": "e9d9eb61238db468076ef374027a1691fa6696f44d4e4472b0123df03dc0d9ea"
},
"downloads": -1,
"filename": "streamlit_geolocation-0.0.10-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f52612594afce165f712d55e6870476a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 802665,
"upload_time": "2023-11-18T15:32:24",
"upload_time_iso_8601": "2023-11-18T15:32:24.798096Z",
"url": "https://files.pythonhosted.org/packages/2b/64/619d0332c50ecb65a5c03c63e78c06855325c8f605459168aa96a06ce042/streamlit_geolocation-0.0.10-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "86e2f3d7da8d0e9892a5f20e53603b08a71cdb98a813193213b2cbcc3bb0e5f3",
"md5": "bdfb19ab4a5e4552dc91392849805847",
"sha256": "0617a39aa26a6019f9b6989e31a310742fe5fe1728321474cf8b5f03a7146d4c"
},
"downloads": -1,
"filename": "streamlit_geolocation-0.0.10.tar.gz",
"has_sig": false,
"md5_digest": "bdfb19ab4a5e4552dc91392849805847",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 795952,
"upload_time": "2023-11-18T15:32:28",
"upload_time_iso_8601": "2023-11-18T15:32:28.958759Z",
"url": "https://files.pythonhosted.org/packages/86/e2/f3d7da8d0e9892a5f20e53603b08a71cdb98a813193213b2cbcc3bb0e5f3/streamlit_geolocation-0.0.10.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-18 15:32:28",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "steffanic",
"github_project": "streamlit-geolocation",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "streamlit-geolocation"
}