Skip to content

Commit 203e49d

Browse files
authored
Merge pull request #893 from martinRenou/merge_featurefound_location_found
SearchControl: Merge on_feature_found and on_location_found
2 parents 66982eb + 8856595 commit 203e49d

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

ipyleaflet/leaflet.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,18 +1895,14 @@ class SearchControl(Control):
18951895
layer = Instance(LayerGroup, allow_none=True, default_value=None).tag(sync=True, **widget_serialization)
18961896

18971897
_location_found_callbacks = Instance(CallbackDispatcher, ())
1898-
_feature_found_callbacks = Instance(CallbackDispatcher, ())
18991898

19001899
def __init__(self, **kwargs):
19011900
super().__init__(**kwargs)
19021901
self.on_msg(self._handle_leaflet_event)
19031902

19041903
def _handle_leaflet_event(self, _, content, buffers):
19051904
if content.get('event', '') == 'locationfound':
1906-
if content.get('feature', None) is not None:
1907-
self._feature_found_callbacks(**content)
1908-
else:
1909-
self._location_found_callbacks(**content)
1905+
self._location_found_callbacks(**content)
19101906

19111907
def on_feature_found(self, callback, remove=False):
19121908
"""Add a found feature event listener for searching in GeoJSON layer.
@@ -1918,7 +1914,7 @@ def on_feature_found(self, callback, remove=False):
19181914
remove: boolean
19191915
Whether to remove this callback or not. Defaults to False.
19201916
"""
1921-
self._feature_found_callbacks.register_callback(callback, remove=remove)
1917+
self._location_found_callbacks.register_callback(callback, remove=remove)
19221918

19231919
def on_location_found(self, callback, remove=False):
19241920
"""Add a found location event listener. The callback will be called when a search result has been found.

0 commit comments

Comments
 (0)