5
5
/* global window */
6
6
7
7
import React , { PureComponent } from 'react' ;
8
- import { Map } from 'react-map-gl/maplibre' ;
8
+ import { Map , useControl } from 'react-map-gl/maplibre' ;
9
+ import { MapboxOverlay } from '@deck.gl/mapbox' ;
9
10
import autobind from 'react-autobind' ;
10
11
11
12
import { DeckGL } from '@deck.gl/react' ;
@@ -42,10 +43,16 @@ const INITIAL_VIEW_STATES = {
42
43
}
43
44
} ;
44
45
45
- const MAP_STYLE = 'https://basemaps.cartocdn.com/gl/positron-nolabels- gl-style/style.json' ;
46
+ const MAP_STYLE = 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json' ;
46
47
47
48
const ViewportLabel = props => < div style = { VIEW_LABEL_STYLES } > { props . children } </ div > ;
48
49
50
+ function DeckGLOverlay ( props ) {
51
+ const overlay = useControl ( ( ) => new MapboxOverlay ( props ) ) ;
52
+ overlay . setProps ( props ) ;
53
+ return null ;
54
+ }
55
+
49
56
export default class DeckMap extends PureComponent {
50
57
constructor ( props ) {
51
58
super ( props ) ;
@@ -55,7 +62,6 @@ export default class DeckMap extends PureComponent {
55
62
hoveredItem : null ,
56
63
clickedItem : null ,
57
64
queriedItems : null ,
58
-
59
65
enableDepthPickOnClick : false ,
60
66
metrics : null
61
67
} ;
@@ -132,45 +138,36 @@ export default class DeckMap extends PureComponent {
132
138
layers,
133
139
views,
134
140
effects,
135
- settings : { pickingRadius, drawPickingColors, useDevicePixels}
141
+ settings : { pickingRadius, drawPickingColors, useDevicePixels, interleaved }
136
142
} = this . props ;
137
143
138
144
return (
139
- < div style = { { backgroundColor : '#eeeeee' } } >
145
+ < div style = { { backgroundColor : '#eeeeee' , height : '100vh' , width : '100vw' } } >
140
146
< div style = { { position : 'absolute' , top : '10px' , left : '100px' , zIndex : 999 } } >
141
147
< RenderMetrics metrics = { this . state . metrics } />
142
148
</ div >
143
- < DeckGL
144
- ref = { this . deckRef }
145
- id = "default-deckgl-overlay"
146
- layers = { layers }
147
- layerFilter = { this . _layerFilter }
148
- views = { views }
149
- initialViewState = { INITIAL_VIEW_STATES }
150
- effects = { effects }
151
- pickingRadius = { pickingRadius }
152
- onHover = { this . _onHover }
153
- onClick = { this . _onClick }
154
- useDevicePixels = { useDevicePixels }
155
- debug = { true }
156
- drawPickingColors = { drawPickingColors }
157
- _onMetrics = { this . _onMetrics }
149
+ < Map
150
+ key = { `map-${ interleaved } ` }
151
+ mapStyle = { MAP_STYLE }
152
+ initialViewState = { INITIAL_VIEW_STATES . basemap }
158
153
>
159
- < View id = "basemap" >
160
- < Map key = "map" mapStyle = { MAP_STYLE } />
161
- < ViewportLabel key = "label" > Map View</ ViewportLabel >
162
- </ View >
163
-
164
- < View id = "first-person" >
165
- < ViewportLabel > First Person View</ ViewportLabel >
166
- </ View >
167
-
168
- < View id = "infovis" >
169
- < ViewportLabel > Orbit View (PlotLayer only, No Navigation)</ ViewportLabel >
170
- </ View >
171
-
154
+ < DeckGLOverlay
155
+ layers = { layers . map ( l => l . clone ( { beforeId : 'watername_ocean' } ) ) }
156
+ initialViewState = { INITIAL_VIEW_STATES }
157
+ layerFilter = { this . _layerFilter }
158
+ { ...( ! interleaved && { views} ) }
159
+ effects = { effects }
160
+ pickingRadius = { pickingRadius }
161
+ onHover = { this . _onHover }
162
+ onClick = { this . _onClick }
163
+ useDevicePixels = { useDevicePixels }
164
+ debug = { true }
165
+ drawPickingColors = { drawPickingColors }
166
+ _onMetrics = { this . _onMetrics }
167
+ interleaved = { interleaved }
168
+ />
172
169
< LayerInfo hovered = { hoveredItem } clicked = { clickedItem } queried = { queriedItems } />
173
- </ DeckGL >
170
+ </ Map >
174
171
</ div >
175
172
) ;
176
173
}
0 commit comments