forked from visgl/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
54 lines (47 loc) · 1.16 KB
/
app.js
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
49
50
51
52
53
54
import React, {Component} from 'react';
import {render} from 'react-dom';
import MapGL from 'react-map-gl';
import DeckGL, {LineLayer} from 'deck.gl';
// Set your mapbox token here
const MAPBOX_TOKEN = process.env.MAPBOX_ACCESS_TOKEN; // eslint-disable-line
class Root extends Component {
constructor(props) {
super(props);
this.state = {
viewport: {
latitude: 37.785164,
longitude: -122.41669,
zoom: 16.140440,
bearing: -20.55991,
pitch: 60
},
width: 500,
height: 500
};
}
render() {
const {viewport, width, height} = this.state;
const layers = [new LineLayer({
data: [{
sourcePosition: [-122.41669, 37.7853],
targetPosition: [-122.41669, 37.781]
}]
})];
return (
<MapGL
{...viewport}
width={width}
height={height}
mapboxApiAccessToken={MAPBOX_TOKEN}>
<DeckGL
{...viewport}
width={width}
height={height}
layers={layers}
debug/>
</MapGL>
);
}
}
/* global document */
render(<Root />, document.body.appendChild(document.createElement('div')));