Deck

Contents

Deck#

class ipydeck.Deck(**kwargs: Any)[source]#

Interactive deck.gl map widget for Jupyter front ends.

The widget mirrors the deck.gl JavaScript API and keeps a serialized representation of the scene in sync with the front-end bundle that lives in ipydeck.static. Only a subset of the traitlets are exposed to the browser; internal counterparts prefixed with an underscore are used for the JSON payload that is consumed by the client.

Examples

Instantiate a Deck with a custom view state and inspect one of the synchronized attributes:

>>> from ipydeck import Deck, ViewState
>>> deck = Deck(
...     layers=[],
...     initial_view_state=ViewState(latitude=37.8, longitude=-122.4, zoom=11),
... )
>>> deck.initial_view_state.latitude
37.8

Create a Deck widget configured with one or more layers.

Parameters:
  • layers – Sequence of Layer instances to render.

  • map_style – Basemap identifier understood by deck.gl or one of the short names defined on ipydeck.base_map.DefaultBaseMap.

  • initial_view_state – Camera configuration for the first render.

  • width – Widget width expressed in pixels or CSS units.

  • height – Widget height expressed in pixels.

  • tooltip – Mapping passed straight through to deck.gl’s tooltip handler.

  • map_provider – Map tile provider identifier; stored for compatibility with the JavaScript side even though it is not consumed directly in Python.

  • api_keys – Provider specific API keys. Retained for symmetry with the front end even if the Python class does not use the value directly.

update()[source]#

Recompute the serialized layer payload.

Call this after mutating a layer in-place so that the front end receives an updated list of serialized layers.

Examples

>>> from ipydeck import Deck
>>> from ipydeck.layers.base import Layer
>>> layer = Layer(type="ScatterplotLayer", data=[{"value": 1}])
>>> deck = Deck(layers=[layer])
>>> layer.opacity = 0.5
>>> deck.update()
>>> deck._layers[0]["opacity"]
0.5