File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ import {scaleQuantile} from 'd3-scale';
1212
1313import type { Color , PickingInfo , MapViewState } from '@deck.gl/core' ;
1414import type { Feature , Polygon , MultiPolygon } from 'geojson' ;
15+ import { CompassWidget , ZoomWidget , FullscreenWidget } from '@deck.gl/widgets' ;
16+ import '@deck.gl/widgets/stylesheet.css' ;
1517
1618// Source data GeoJSON
1719const DATA_URL =
@@ -142,6 +144,7 @@ export default function App({
142144 initialViewState = { INITIAL_VIEW_STATE }
143145 controller = { true }
144146 getTooltip = { getTooltip }
147+ widgets = { [ new ZoomWidget ( { } ) , new CompassWidget ( { } ) , new FullscreenWidget ( { } ) ] }
145148 >
146149 < Map reuseMaps mapStyle = { mapStyle } />
147150 </ DeckGL >
Original file line number Diff line number Diff line change @@ -1072,7 +1072,9 @@ export default class Deck<ViewsT extends ViewOrViews = null> {
10721072 timeline . play ( ) ;
10731073 this . animationLoop . attachTimeline ( timeline ) ;
10741074
1075- this . eventManager = new EventManager ( this . props . parent || this . canvas , {
1075+ const eventRoot =
1076+ this . props . parent ?. querySelector < HTMLDivElement > ( '.deck-events-root' ) || this . canvas ;
1077+ this . eventManager = new EventManager ( eventRoot , {
10761078 touchAction : this . props . touchAction ,
10771079 recognizers : Object . keys ( RECOGNIZERS ) . map ( ( eventName : string ) => {
10781080 // Resolve recognizer settings
@@ -1128,9 +1130,13 @@ export default class Deck<ViewsT extends ViewOrViews = null> {
11281130
11291131 this . deckPicker = new DeckPicker ( this . device ) ;
11301132
1133+ const widgetParent =
1134+ this . props . parent ?. querySelector < HTMLDivElement > ( '.deck-widgets-root' ) ||
1135+ this . canvas ?. parentElement ;
1136+
11311137 this . widgetManager = new WidgetManager ( {
11321138 deck : this ,
1133- parentElement : this . canvas ?. parentElement
1139+ parentElement : widgetParent
11341140 } ) ;
11351141 this . widgetManager . addDefault ( new TooltipWidget ( ) ) ;
11361142
Original file line number Diff line number Diff line change @@ -259,11 +259,26 @@ function DeckGLWithRef<ViewsT extends ViewOrViews = null>(
259259 style : canvasStyle
260260 } ) ;
261261
262+ const eventRoot = createElement (
263+ 'div' ,
264+ {
265+ key : 'deck-events-root' ,
266+ className : 'deck-events-root' ,
267+ style : { width, height}
268+ } ,
269+ [ canvas , childrenUnderViews ]
270+ ) ;
271+
272+ const widgetRoot = createElement ( 'div' , {
273+ key : 'deck-widgets-root' ,
274+ className : 'deck-widgets-root'
275+ } ) ;
276+
262277 // Render deck.gl as the last child
263278 thisRef . control = createElement (
264279 'div' ,
265280 { id : `${ id || 'deckgl' } -wrapper` , ref : containerRef , style : containerStyle } ,
266- [ canvas , childrenUnderViews ]
281+ [ eventRoot , widgetRoot ]
267282 ) ;
268283 }
269284
You can’t perform that action at this time.
0 commit comments