Skip to main content

ViewSelectorWidget (Experimental)

from v9.2

Provides a dropdown menu for selecting different view modes including single view and split view configurations.

Usage

import {Deck} from '@deck.gl/core';
import {_ViewSelectorWidget as ViewSelectorWidget} from '@deck.gl/widgets';

const deck = new Deck({
widgets: [
new ViewSelectorWidget({
initialViewMode: 'single',
onViewModeChange: (mode) => {
console.log('View mode changed to:', mode);
// Handle view configuration changes
}
})
]
});

Types

ViewSelectorWidgetProps

The ViewSelectorWidget accepts the generic WidgetProps and:

  • initialViewMode (ViewMode, default 'single') - Initial view mode selection
  • onViewModeChange (function, optional) - Callback invoked when view mode changes. Receives the new ViewMode.
  • label (string, default 'Split View') - Tooltip label for the widget

ViewMode

Available view modes:

  • 'single' - Single view display
  • 'split-horizontal' - Two views split horizontally (top/bottom)
  • 'split-vertical' - Two views split vertically (left/right)

Behavior

  • Click the button to open a dropdown menu with view mode options
  • Each option shows an icon representing the layout
  • Selection updates the current view mode internally
  • The widget button displays an icon matching the currently selected mode

Integration

This widget provides the UI for view mode selection but does not currently trigger callbacks or modify deck.gl view configuration automatically. Applications need to implement custom logic to detect view mode changes and update view configurations accordingly.

Source

modules/widgets/src/view-selector-widget.tsx