peek_layerο
- click_callbacks.peek_layer(layer='1', how=(0.4, 0.4), alpha=1, shape='rectangular', **kwargs)ο
Overlay a part of the map with a different layer if you click on the map.
This callback allows you to overlay one (or more) existing layers on top of the currently visible layer if you click on the map.
You can show a rectangular or circular area of the βpeek-layerβ centered at the mouse-position or swipe beween layers (e.g. from left/right/top or bottom).
- Parameters:
layer (str or list) β
if str: The name of the layer you want to peek at.
if list: A list of layer-names of the following form:
A layer-name (string)
A tuple (< layer-name >, < transparency [0-1] >)
see m.show_layer() for more details on how to provide combined layer-names
how (str , float or tuple, optional) β
The method you want to visualize the second layer. (e.g. swipe from a side or display a rectangle)
βleftβ (β), βrightβ (β), βtopβ (β), βbottomβ (β): swipe the layer at the mouse-position.
βfullβ: overlay the layer on the whole figure
if float: peek a square at the mouse-position, specified as percentage of the axis-width (0-1)
if tuple: (width, height) peek a rectangle at the mouse-position, specified as percentage of the axis-size (0-1)
The default is βleftβ.
alpha (float, optional) β The transparency of the peeked layer. (between 0 and 1) If you overlay a (possibly transparent) combination of multiple layers, this transparency will be assigned as a global transparency for the obtained βcombined layerβ. The default is 1.
**kwargs β additional kwargs passed to a rectangle-marker. the default is (fc=βnoneβ, ec=βkβ, lw=1)
Examples
Overlay a single layer:
>>> m = Maps() >>> m.add_feature.preset.coastline() >>> m2 = m.new_layer(layer="ocean") >>> m2.add_feature.preset.ocean() >>> m.cb.click.attach.peek_layer(layer="ocean")
Overlay a (transparent) combination of multiple layers:
>>> m = Maps() >>> m.all.add_feature.preset.coastline() >>> m.add_feature.preset.urban_areas() >>> m.add_feature.preset.ocean(layer="ocean") >>> m.add_feature.physical.land(layer="land", fc="g") >>> m.cb.click.attach.peek_layer(layer=["ocean", ("land", 0.5)], >>> shape="round", how=0.4)