peek_layer

PickCallbacks.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 between 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.

  • shape (str, optional) –

    The shape of the peek-window.

    • ”rectangular”: peek a rectangle

    • ”round”: peek an ellipse

    The default is “rectangular”

  • **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)