@@ -2,8 +2,13 @@ import * as React from "react";
2
2
import { useState , useEffect } from "react" ;
3
3
import { createRender , useModelState , useModel } from "@anywidget/react" ;
4
4
import type { Initialize , Render } from "@anywidget/types" ;
5
- import Map from "react-map-gl/maplibre" ;
6
- import DeckGL from "@deck.gl/react/typed" ;
5
+ import { MapboxOverlay , MapboxOverlayProps } from "@deck.gl/mapbox/typed" ;
6
+ import Map , {
7
+ FullscreenControl ,
8
+ NavigationControl ,
9
+ ScaleControl ,
10
+ useControl ,
11
+ } from "react-map-gl/maplibre" ;
7
12
import { MapViewState , type Layer } from "@deck.gl/core/typed" ;
8
13
import { BaseLayerModel , initializeLayer } from "./model/index.js" ;
9
14
import type { WidgetModel } from "@jupyter-widgets/base" ;
@@ -14,6 +19,8 @@ import { v4 as uuidv4 } from "uuid";
14
19
import { Message } from "./types.js" ;
15
20
import { flyTo } from "./actions/fly-to.js" ;
16
21
22
+ import "maplibre-gl/dist/maplibre-gl.css" ;
23
+
17
24
await initParquetWasm ( ) ;
18
25
19
26
const DEFAULT_INITIAL_VIEW_STATE = {
@@ -27,6 +34,16 @@ const DEFAULT_INITIAL_VIEW_STATE = {
27
34
const DEFAULT_MAP_STYLE =
28
35
"https://basemaps.cartocdn.com/gl/positron-nolabels-gl-style/style.json" ;
29
36
37
+ function DeckGLOverlay (
38
+ props : MapboxOverlayProps & {
39
+ interleaved ?: boolean ;
40
+ } ,
41
+ ) {
42
+ const overlay = useControl < MapboxOverlay > ( ( ) => new MapboxOverlay ( props ) ) ;
43
+ overlay . setProps ( props ) ;
44
+ return null ;
45
+ }
46
+
30
47
async function getChildModelState (
31
48
childModels : WidgetModel [ ] ,
32
49
childLayerIds : string [ ] ,
@@ -146,29 +163,33 @@ function App() {
146
163
147
164
return (
148
165
< div id = { `map-${ mapId } ` } style = { { height : mapHeight || "100%" } } >
149
- < DeckGL
166
+ < Map
150
167
initialViewState = {
151
168
[ "longitude" , "latitude" , "zoom" ] . every ( ( key ) =>
152
169
Object . keys ( initialViewState ) . includes ( key ) ,
153
170
)
154
171
? initialViewState
155
172
: DEFAULT_INITIAL_VIEW_STATE
156
173
}
157
- controller = { true }
158
- layers = { layers }
159
- // @ts -expect-error
160
- getTooltip = { showTooltip && getTooltip }
161
- pickingRadius = { pickingRadius }
162
- useDevicePixels = { isDefined ( useDevicePixels ) ? useDevicePixels : true }
163
- // https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
164
- _typedArrayManagerProps = { {
165
- overAlloc : 1 ,
166
- poolSize : 0 ,
167
- } }
168
- parameters = { parameters || { } }
174
+ mapStyle = { mapStyle || DEFAULT_MAP_STYLE }
169
175
>
170
- < Map mapStyle = { mapStyle || DEFAULT_MAP_STYLE } />
171
- </ DeckGL >
176
+ < DeckGLOverlay
177
+ layers = { layers }
178
+ // @ts -expect-error
179
+ getTooltip = { showTooltip && getTooltip }
180
+ pickingRadius = { pickingRadius }
181
+ useDevicePixels = { isDefined ( useDevicePixels ) ? useDevicePixels : true }
182
+ // https://deck.gl/docs/api-reference/core/deck#_typedarraymanagerprops
183
+ _typedArrayManagerProps = { {
184
+ overAlloc : 1 ,
185
+ poolSize : 0 ,
186
+ } }
187
+ parameters = { parameters || { } }
188
+ />
189
+ < NavigationControl />
190
+ < ScaleControl />
191
+ < FullscreenControl />
192
+ </ Map >
172
193
</ div >
173
194
) ;
174
195
}
0 commit comments