File tree Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Expand file tree Collapse file tree 3 files changed +27
-2
lines changed Original file line number Diff line number Diff line change 5050 "execution_count" : null ,
5151 "metadata" : {},
5252 "outputs" : [],
53- "source" : []
53+ "source" : [
54+ " layer.visible = False"
55+ ]
56+ },
57+ {
58+ "cell_type" : " code" ,
59+ "execution_count" : null ,
60+ "metadata" : {},
61+ "outputs" : [],
62+ "source" : [
63+ " layer.visible = True"
64+ ]
5465 }
5566 ],
5667 "metadata" : {
6980 "name" : " python" ,
7081 "nbconvert_exporter" : " python" ,
7182 "pygments_lexer" : " ipython3" ,
72- "version" : " 3.9.7 "
83+ "version" : " 3.10.5 "
7384 }
7485 },
7586 "nbformat" : 4 ,
Original file line number Diff line number Diff line change @@ -1236,6 +1236,7 @@ class GeoJSON(FeatureGroup):
12361236
12371237 data = Dict ().tag (sync = True )
12381238 style = Dict ().tag (sync = True )
1239+ visible = Bool (True ).tag (sync = True )
12391240 hover_style = Dict ().tag (sync = True )
12401241 point_style = Dict ().tag (sync = True )
12411242 style_callback = Any ()
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export class LeafletGeoJSONModel extends featuregroup.LeafletFeatureGroupModel {
1212 _model_name : 'LeafletGeoJSONModel' ,
1313 data : { } ,
1414 style : { } ,
15+ visible : true ,
1516 hover_style : { } ,
1617 point_style : { }
1718 } ;
@@ -82,5 +83,17 @@ export class LeafletGeoJSONView extends featuregroup.LeafletFeatureGroupView {
8283 } ,
8384 this
8485 ) ;
86+ this . listenTo (
87+ this . model ,
88+ 'change:visible' ,
89+ function ( ) {
90+ if ( this . model . get ( 'visible' ) ) {
91+ this . obj . addData ( this . model . get ( 'data' ) ) ;
92+ } else {
93+ this . obj . clearLayers ( ) ;
94+ }
95+ } ,
96+ this
97+ ) ;
8598 }
8699}
You can’t perform that action at this time.
0 commit comments