File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -497,6 +497,24 @@ class Popup(UILayer):
497
497
auto_close = Bool (True ).tag (sync = True , o = True )
498
498
close_on_escape_key = Bool (True ).tag (sync = True , o = True )
499
499
500
+ def open_popup (self , location = None ):
501
+ """Open the popup on the bound map.
502
+
503
+ Parameters
504
+ ----------
505
+ location: list, default to the internal location
506
+ The location to open the popup at.
507
+ """
508
+
509
+ if location is not None :
510
+ self .location = location
511
+ self .send ({'msg' : 'open' , 'location' : self .location if location is None else location })
512
+
513
+ def close_popup (self ):
514
+ """Close the popup on the bound map."""
515
+
516
+ self .send ({'msg' : 'close' })
517
+
500
518
501
519
class RasterLayer (Layer ):
502
520
"""Abstract RasterLayer class.
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ export class LeafletPopupView extends layer.LeafletUILayerView {
34
34
this . obj = L . popup ( this . get_options ( ) ) . setLatLng (
35
35
this . model . get ( 'location' )
36
36
) ;
37
+ this . model . on ( 'msg:custom' , this . handle_message . bind ( this ) ) ;
37
38
}
38
39
39
40
initialize ( parameters ) {
@@ -115,4 +116,11 @@ export class LeafletPopupView extends layer.LeafletUILayerView {
115
116
this . map_view . obj . closePopup ( this . obj ) ;
116
117
}
117
118
}
119
+ handle_message ( content ) {
120
+ if ( content . msg == 'open' ) {
121
+ this . map_view . obj . openPopup ( this . obj , content . location ) ;
122
+ } else if ( content . msg == 'close' ) {
123
+ this . map_view . obj . closePopup ( this . obj ) ;
124
+ }
125
+ }
118
126
}
You can’t perform that action at this time.
0 commit comments