Maps.cb.keypress.attach.overlay_layer#
- attach.overlay_layer(layer, key='x')#
Toggle displaying a layer on top of the currently visible layers.
This callback is useful to quickly show/hide a data-layer on top of a basemap by pressing a key on the keyboard.
- Parameters:
layer (str, tuple or list) –
The layer-name to use, a tuple (layer, transparency) or a list of the aforementioned types to combine.
For details on how to specify layer-names, see
Maps.show_layer()Parameters (Additional)
---------------------
key (str, optional) – The key to use for triggering the callback. Modifiers are indicated with a “+”, e.g. “alt+x”. The default is “x”.
Note
If the visible layer changes while the overlay-layer is active, triggering the callback again might not properly remove the previous overlay! (e.g. the overlay is only removed if the top-layer corresponds exactly to the overlay-layer specifications)
Examples
Toggle overlaying layer A:
>>> m.cb.keypress.attach.overlay_layer(layer="A", key="x")
Toggle overlaying layer A with 50% transparency:
>>> m.cb.keypress.attach.overlay_layer(layer=("A", 0.5), key="x")
Toggle overlaying a combined layer (showing layer B with 50% transparency on top of layer A)
>>> m.cb.keypress.attach.overlay_layer(layer="A|B{0.5}", key="x")
Toggle overlaying a combined layer (showing layer B on top of layer A)
>>> m.cb.keypress.attach.overlay_layer(layer=["A", "B"], key="x")
Toggle overlaying a combined layer (showing layer B with 50% transparency on top of layer A)
>>> m.cb.keypress.attach.overlay_layer(layer=["A", ("B", 0.5)], key="x")