Skip to content

Commit 8879c30

Browse files
amrsalah944pre-commit-ci[bot]giswqs
authored
Fix map interaction bug (#397)
* Fix: Prevent map from adding points when clicking UI elements * Fix: Prevent map from adding points when clicking UI elements IDNETATION * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix docs build error --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Qiusheng Wu <giswqs@gmail.com>
1 parent 42a5f92 commit 8879c30

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

requirements_docs.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mkdocs-material>=9.1.3
1515
mkdocs-pdf-export-plugin
1616
mkdocstrings
1717
mkdocstrings-crystal
18-
mkdocstrings-python-legacy
18+
mkdocstrings-python
1919
nbconvert
2020
nbformat
2121
pip

samgeo/common.py

+13
Original file line numberDiff line numberDiff line change
@@ -1894,6 +1894,16 @@ def sam_map_gui(sam, basemap="SATELLITE", repeat_mode=True, out_dir=None, **kwar
18941894
layout=widgets.Layout(width=widget_width, padding=padding),
18951895
)
18961896

1897+
def on_radio_button_click(change):
1898+
# Set a flag to indicate UI interaction is happening
1899+
m._ui_interaction = True
1900+
# Use a small delay to reset the flag after the event is processed
1901+
import threading
1902+
1903+
threading.Timer(0.1, lambda: setattr(m, "_ui_interaction", False)).start()
1904+
1905+
radio_buttons.observe(on_radio_button_click, "value")
1906+
18971907
fg_count = widgets.IntText(
18981908
value=0,
18991909
description="Foreground #:",
@@ -2110,6 +2120,9 @@ def close_btn_click(change):
21102120
def handle_map_interaction(**kwargs):
21112121
try:
21122122
if kwargs.get("type") == "click":
2123+
# Skip if we're interacting with UI
2124+
if hasattr(m, "_ui_interaction") and m._ui_interaction:
2125+
return
21132126
latlon = kwargs.get("coordinates")
21142127
if radio_buttons.value == "Foreground":
21152128
if is_colab():

0 commit comments

Comments
 (0)