A widget is a UI component that can interact with deck.gl's layers and views.
You can write your own widgets, or use any of the many ready-to-use widgets in the @deck.gl/widgets module.
The Widget class is a base class used to define new widgets and should not be instantiated directly by an application. See the Widget Documentation for information about how to write your own widgets.
Options for the widget, as passed into the constructor and can be updated with setProps.
- Default: the widget's name.
The id string must be unique among all your widgets at a given time. While a default id is provided, it is recommended to set id explicitly if you have multiple widgets of the same type.
Remarks:
idis used to match widgets between rendering calls. deck.gl requires each widget to have a uniqueid. A defaultidis assigned based on widget type, which means if you are using more than one widget of the same type (e.g. twoInfoWidgets) you need to provide a customidfor at least one of them.
- Default:
{}
Additional inline CSS styles on the top HTML element of the widget. camelCase CSS properties (e.g. backgroundColor) and kebab-case CSS variables are accepted (e.g. --button-size).
style?: Partial<CSSStyleDeclaration>;- Default:
''
Additional CSS classnames on the top HTML element.
Experimental. Selects the DOM container used for this widget. Defaults to viewId.
- If set to
'root', the widget is placed relative to the shared widget root. - If set to a valid view id, the widget is placed relative to that view.
- If set to an HTMLElement,
placementis ignored and the widget is appended into the given element.
- Default:
null
The viewId prop controls both positioning and event scope. If defined, the widget is positioned relative to the matching view and only responds to events inside that view. If null, the widget is positioned in the shared root widget container and receives events from all views.
- Default:
'top-left'
Widget positioning within the selected view, or within the shared widget root when viewId is null. One of:
'top-left''top-right''bottom-left''bottom-right''fill'
Supply the props and default props to the base class.
Called to update widget options.
Updates the widget. Called by the specific widget when state has changed. Calls onRenderHTML()
This function is implemented by the specific widget subclass to update the HTML for the widget
Required. Called when the widget is added to a Deck instance.
Receives the following arguments:
context(object)deck(Deck) - the Deck instance that this widget is being attached to.viewId(string | null) - the view id that this widget is being attached to.
Returns an optional UI element that should be appended to the Deck container.
Optional. Called when the widget is removed.
Op†ional. Called when the containing view is changed. If viewId: null, will be called if any viewport changes.
Receives the following arguments:
viewport(Viewport) - the viewport that has changed
Optional. Called when the containing view is redrawn. If viewId: null, will be called if anything redraws.
Receives the following arguments:
paramsviewports(Viewport[]) - the viewports that are being redrawnlayers(Layer[]) - the layers that are being redrawn
Optional. Called when a hover event occurs in the containing view. If viewId: null, will be called if hover occurs in any view.
Receives arguments:
info- the picking info describing the object being hovered.event- the original gesture event
Optional. Called when a click event occurs in the containing view. If viewId: null, will be called if click occurs in any view.
Receives arguments:
info- the picking info describing the object being clicked.event- the original gesture event
Optional. Called when a dragstart event occurs in the containing view. If viewId: null, will be called if drag occurs in any view.
Receives arguments:
info- the picking info describing the object being dragged.event- the original gesture event
Optional. Called when a drag event occurs in the containing view. If viewId: null, will be called if drag occurs in any view.
Receives arguments:
info- the picking info describing the object being dragged.event- the original gesture event
Optional. Called when a dragend event occurs in the containing view. If viewId: null, will be called if drag occurs in any view.
Receives arguments:
info- the picking info describing the object being dragged.event- the original gesture event