@@ -1894,15 +1894,19 @@ class SearchControl(Control):
1894
1894
marker = Instance (Marker , allow_none = True , default_value = None ).tag (sync = True , ** widget_serialization )
1895
1895
layer = Instance (LayerGroup , allow_none = True , default_value = None ).tag (sync = True , ** widget_serialization )
1896
1896
1897
+ _location_found_callbacks = Instance (CallbackDispatcher , ())
1897
1898
_feature_found_callbacks = Instance (CallbackDispatcher , ())
1898
1899
1899
1900
def __init__ (self , ** kwargs ):
1900
1901
super ().__init__ (** kwargs )
1901
1902
self .on_msg (self ._handle_leaflet_event )
1902
1903
1903
1904
def _handle_leaflet_event (self , _ , content , buffers ):
1904
- if content .get ('event' , '' ) == 'found' :
1905
- self ._feature_found_callbacks (** content )
1905
+ 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 )
1906
1910
1907
1911
def on_feature_found (self , callback , remove = False ):
1908
1912
"""Add a found feature event listener for searching in GeoJSON layer.
@@ -1916,6 +1920,18 @@ def on_feature_found(self, callback, remove=False):
1916
1920
"""
1917
1921
self ._feature_found_callbacks .register_callback (callback , remove = remove )
1918
1922
1923
+ def on_location_found (self , callback , remove = False ):
1924
+ """Add a found location event listener. The callback will be called when a search result has been found.
1925
+
1926
+ Parameters
1927
+ ----------
1928
+ callback : callable
1929
+ Callback function that will be called on location found event.
1930
+ remove: boolean
1931
+ Whether to remove this callback or not. Defaults to False.
1932
+ """
1933
+ self ._location_found_callbacks .register_callback (callback , remove = remove )
1934
+
1919
1935
1920
1936
class MapStyle (Style , Widget ):
1921
1937
"""Map Style Widget
0 commit comments