{"id":14959606,"url":"https://github.com/reyemb/streamlit-plotly-mapbox-events","last_synced_at":"2025-05-02T12:31:29.631Z","repository":{"id":57471761,"uuid":"453423755","full_name":"reyemb/streamlit-plotly-mapbox-events","owner":"reyemb","description":"Interactive Mapbox Component for Streamlit: An intuitive and customizable interface integrating Streamlit with Plotly Mapbox. Enables four interactive events - click point, select point, hover point, and relayout, returning their respective responses to the Python user. Designed using React.js","archived":false,"fork":false,"pushed_at":"2024-09-18T12:24:20.000Z","size":78680,"stargazers_count":25,"open_issues_count":2,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-21T11:58:47.716Z","etag":null,"topics":["interactive-maps","python","reactjs","streamlit","streamlit-component","streamlit-components"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reyemb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-29T14:38:57.000Z","updated_at":"2025-04-17T17:29:45.000Z","dependencies_parsed_at":"2024-09-24T13:47:16.711Z","dependency_job_id":null,"html_url":"https://github.com/reyemb/streamlit-plotly-mapbox-events","commit_stats":{"total_commits":4,"total_committers":2,"mean_commits":2.0,"dds":0.25,"last_synced_commit":"2ada1a683605b082d6260aa0e5706cdcde24cc5f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reyemb%2Fstreamlit-plotly-mapbox-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reyemb%2Fstreamlit-plotly-mapbox-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reyemb%2Fstreamlit-plotly-mapbox-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reyemb%2Fstreamlit-plotly-mapbox-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reyemb","download_url":"https://codeload.github.com/reyemb/streamlit-plotly-mapbox-events/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252038152,"owners_count":21684632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interactive-maps","python","reactjs","streamlit","streamlit-component","streamlit-components"],"created_at":"2024-09-24T13:20:12.659Z","updated_at":"2025-05-02T12:31:24.622Z","avatar_url":"https://github.com/reyemb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Streamlit Plotly MapBox Events\n\n![PyPI](https://img.shields.io/pypi/v/streamlit-plotly-mapbox-events)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/streamlit-plotly-mapbox-events)\n\n\n![Example Image](https://github.com/reyemb/streamlit-plotly-mapbox-events/blob/main/example.gif)\n=======\n\n## First things first\n\nThis Repository is heavily inspired my [Null Jones - Plotly Events](https://github.com/null-jones/streamlit-plotly-events)\n\nSince it didn't cover scattermaps in a way I need. I decided to reuse her repository and fit it to the needs of a scattermap\n\n### Installation\n\nInstall via Pip!\n\n```pip install streamlit-plotly-mapbox-events```\n=======\n\n\n### Usage\n\nImport the component, and use it like any other Streamlit custom component!\n```python\nimport streamlit as st\n\nfrom streamlit_plotly_mapbox_events import plotly_mapbox_events\nimport plotly.express as px\nimport pandas as pd\n\n# Create a sample dataframe\ndf = pd.DataFrame({\n    'lat': [49.058, 50.383, 49.599, 50.677, 53.036, 50.541, 51.524, 54.992, 49.88],\n    'lon': [11.115, 12.528, 11.231, 10.408, 8.185, 8.055, 7.639, 11.636, 7.678],\n    'hover': [1, 2, 3, 4, 5, 6, 7, 8, 9],\n    'color_1': [3, 3, 4, 3, 5, 5, 5, 4, 2],\n    'color_2': [5, 5, 3, 1, 1, 2, 5, 2, 2],\n    'color_3': [3, 2, 1, 5, 3, 2, 5, 2, 2]\n})\n\n# Create a Plotly Mapbox figure\nmapbox = px.scatter_mapbox(df, lat=\"lat\", lon=\"lon\", hover_name=\"hover\", zoom=5.5, height=600)\nmapbox.update_layout(mapbox_style=\"carto-positron\")\nmapbox.update_layout(margin={\"r\":0, \"t\":0, \"l\":0, \"b\":0})\n\n# Create an instance of the plotly_mapbox_events component\nmapbox_events = plotly_mapbox_events(\n    mapbox,\n    click_event=True,\n    select_event=True,\n    hover_event=True,\n    override_height=600\n)\n\n# Display the captured events\nplot_name_holder_clicked = st.empty()\nplot_name_holder_selected = st.empty()\nplot_name_holder_hovered = st.empty()\n\nplot_name_holder_clicked.write(f\"Clicked Point: {mapbox_events[0]}\")\nplot_name_holder_selected.write(f\"Selected Point: {mapbox_events[1]}\")\nplot_name_holder_hovered.write(f\"Hovered Point: {mapbox_events[2]}\")\n```\n\n## Parameters\n- plot_fig (Plotly Figure): Plotly figure that we want to render in Streamlit.\n- click_event (boolean, default: True): Watch for click events on plot and return point data when triggered.\n- select_event (boolean, default: False): Watch for select events on plot and return point data when triggered.\n- hover_event (boolean, default: False): Watch for hover events on plot and return point data when triggered.\n- override_height (int, default: 450): Integer to override component height. Defaults to 450 (px).\n- override_width (string, default: '100%'): String (or integer) to override width. Defaults to 100% (whole width of iframe).\n- key (str or None): An optional key that uniquely identifies this component. If this is None, and the component's arguments are changed, the component will be re-mounted in the Streamlit frontend and lose its current state.\n\n\n## Return Value\n\nA tuple consisting of lists or dictionaries for the captured events:\n\nClick Event\nSelect Event\nHover Event\nFor selected, click, and hover events, a list of dictionaries containing marker details is returned (in case multiple overlapping markers have been clicked/selected/hovered). The dictionary format is as follows:\n```python\n{\n    'lat': int (lat value of point),\n    'lon': int (lon value of point),\n    'pointNumber': (index of selected point),\n    'pointIndex': (index of selected point)\n}\n```\n\n## Events\nCurrently, a number of plotly events can be enabled.  They can be enabled/disabled using kwargs on the `plotly_event()` function.\n- **Click** `click_event` (defaults to `True`): Triggers event on mouse click of marker\n- **Select** `select_event`: Triggers event when markers have been selected\n- **Hover** `hover_event`: Triggers event on mouse hover of marker\n- **Relayout** `relayout_event`: Triggers if the layout has changed. Occurs on Zoom and Moving\n\n## Deprecation Warning\nThe relayout_event parameter is deprecated and will have no effect. Relayout events have been removed due to interferences with Streamlit.\n=======\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freyemb%2Fstreamlit-plotly-mapbox-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freyemb%2Fstreamlit-plotly-mapbox-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freyemb%2Fstreamlit-plotly-mapbox-events/lists"}