From a44f7be34698694fc18fe545594955618512ead5 Mon Sep 17 00:00:00 2001 From: Ronan Date: Wed, 5 Jun 2024 17:26:13 +0200 Subject: [PATCH] feat: fix issue with zoom reset --- app/callbacks/display_callbacks.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/callbacks/display_callbacks.py b/app/callbacks/display_callbacks.py index b7357e9..b432b08 100644 --- a/app/callbacks/display_callbacks.py +++ b/app/callbacks/display_callbacks.py @@ -419,7 +419,7 @@ def update_download_link(slider_value, alert_data, media_url): """ alert_data, data_loaded = read_stored_DataFrame(alert_data) if data_loaded and len(alert_data): - event_id, media_id = alert_data.iloc[slider_value][["event_id", "media_id"]] + event_id, media_id = alert_data.iloc[slider_value][["event_id", "media_id"]] # BUG ? IndexError: single positional indexer is out-of-bounds if str(event_id) in media_url.keys(): return media_url[str(event_id)][str(media_id)] return "" # Return empty string if no image URL is available @@ -529,3 +529,15 @@ def toggle_fullscreen_map(n_clicks_open, is_open): if n_clicks_open: return not is_open # Toggle the modal return is_open # Keep the current state + + +# Define the callback to reset the zoom level +@app.callback( + Output("map", "zoom"), + [Input({"type": "event-button", "index": ALL}, "n_clicks"),] +) +def reset_zoom(n_clicks): + print("ON RESET LE ZOOM") + if n_clicks: + return 10 # Reset zoom level to 10 + return dash.no_update \ No newline at end of file