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 50
50
"execution_count" : null ,
51
51
"metadata" : {},
52
52
"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
+ ]
54
65
}
55
66
],
56
67
"metadata" : {
69
80
"name" : " python" ,
70
81
"nbconvert_exporter" : " python" ,
71
82
"pygments_lexer" : " ipython3" ,
72
- "version" : " 3.9.7 "
83
+ "version" : " 3.10.5 "
73
84
}
74
85
},
75
86
"nbformat" : 4 ,
Original file line number Diff line number Diff line change @@ -1236,6 +1236,7 @@ class GeoJSON(FeatureGroup):
1236
1236
1237
1237
data = Dict ().tag (sync = True )
1238
1238
style = Dict ().tag (sync = True )
1239
+ visible = Bool (True ).tag (sync = True )
1239
1240
hover_style = Dict ().tag (sync = True )
1240
1241
point_style = Dict ().tag (sync = True )
1241
1242
style_callback = Any ()
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export class LeafletGeoJSONModel extends featuregroup.LeafletFeatureGroupModel {
12
12
_model_name : 'LeafletGeoJSONModel' ,
13
13
data : { } ,
14
14
style : { } ,
15
+ visible : true ,
15
16
hover_style : { } ,
16
17
point_style : { }
17
18
} ;
@@ -82,5 +83,17 @@ export class LeafletGeoJSONView extends featuregroup.LeafletFeatureGroupView {
82
83
} ,
83
84
this
84
85
) ;
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
+ ) ;
85
98
}
86
99
}
You can’t perform that action at this time.
0 commit comments