@@ -80,6 +80,11 @@ def get_value(change):
80
80
return future
81
81
82
82
83
+ class PaneException (TraitError ):
84
+ """Custom PaneException class."""
85
+ pass
86
+
87
+
83
88
class LayerException (TraitError ):
84
89
"""Custom LayerException class."""
85
90
pass
@@ -112,6 +117,8 @@ class Layer(Widget, InteractMixin):
112
117
Custom name for the layer, which will be used by the LayersControl.
113
118
popup: object
114
119
Interactive widget that will be shown in a Popup when clicking on the layer.
120
+ pane: string
121
+ Name of the pane to use for the layer.
115
122
"""
116
123
117
124
_view_name = Unicode ('LeafletLayerView' ).tag (sync = True )
@@ -129,6 +136,7 @@ class Layer(Widget, InteractMixin):
129
136
popup_min_width = Int (50 ).tag (sync = True )
130
137
popup_max_width = Int (300 ).tag (sync = True )
131
138
popup_max_height = Int (default_value = None , allow_none = True ).tag (sync = True )
139
+ pane = Unicode ('' ).tag (sync = True )
132
140
133
141
options = List (trait = Unicode ()).tag (sync = True )
134
142
@@ -2181,6 +2189,7 @@ def _default_options(self):
2181
2189
right = Float (0 , read_only = True ).tag (sync = True )
2182
2190
left = Float (9007199254740991 , read_only = True ).tag (sync = True )
2183
2191
2192
+ panes = Dict ().tag (sync = True )
2184
2193
layers = Tuple ().tag (trait = Instance (Layer ), sync = True , ** widget_serialization )
2185
2194
2186
2195
@default ('layers' )
@@ -2243,6 +2252,19 @@ def observe_attribution_control(self, change):
2243
2252
if self .attribution_control_instance is not None and self .attribution_control_instance in self .controls :
2244
2253
self .remove (self .attribution_control_instance )
2245
2254
2255
+ @validate ('panes' )
2256
+ def _validate_panes (self , proposal ):
2257
+ '''Validate panes.
2258
+ '''
2259
+ error_msg = "Panes should look like: {'pane_name': {'zIndex': 650, 'pointerEvents': 'none'}, ...}"
2260
+ for k1 , v1 in proposal .value .items ():
2261
+ if not isinstance (k1 , str ) or not isinstance (v1 , dict ):
2262
+ raise PaneException (error_msg )
2263
+ for k2 , v2 in v1 .items ():
2264
+ if not isinstance (k2 , str ) or not isinstance (v2 , (str , int , float )):
2265
+ raise PaneException (error_msg )
2266
+ return proposal .value
2267
+
2246
2268
_layer_ids = List ()
2247
2269
2248
2270
@validate ('layers' )
0 commit comments