-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
48 lines (40 loc) · 1.24 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import React from 'react';
import DeckGL from '@deck.gl/react';
import {LineLayer} from '@deck.gl/layers';
import {StaticMap} from 'react-map-gl';
// Set your mapbox access token here
const MAPBOX_ACCESS_TOKEN = 'your_mapbox_token';
// Viewport settings
const INITIAL_VIEW_STATE = {
longitude: -122.41669,
latitude: 37.7853,
zoom: 13,
pitch: 0,
bearing: 0
};
// Data to be used by the LineLayer
const data = [
{sourcePosition: [-122.41669, 37.7853], targetPosition: [-122.41669, 37.781]}
];
function App() {
const getLayers = (id: string) => [
new LineLayer({id: 'line-layer', data})
];
return (
<>
<h1>learn react</h1>
{/* Without children */}
<DeckGL initialViewState={INITIAL_VIEW_STATE} controller={true} layers={getLayers('1')} />
{/* With single child */}
<DeckGL initialViewState={INITIAL_VIEW_STATE} controller={true} layers={getLayers('2')}>
<StaticMap mapboxApiAccessToken={MAPBOX_ACCESS_TOKEN} />
</DeckGL>
{/* With multiple children */}
<DeckGL initialViewState={INITIAL_VIEW_STATE} controller={true} layers={getLayers('3')}>
<StaticMap mapboxApiAccessToken={MAPBOX_ACCESS_TOKEN} />
<div>Lorem ipsum</div>
</DeckGL>
</>
);
}
export default App