forked from visgl/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeckgl-overlay.js
More file actions
42 lines (35 loc) · 876 Bytes
/
deckgl-overlay.js
File metadata and controls
42 lines (35 loc) · 876 Bytes
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
import React, {Component} from 'react';
import DeckGL, {ScatterplotLayer} from 'deck.gl';
export default class DeckGLOverlay extends Component {
static get defaultViewport() {
return {
longitude: -74,
latitude: 40.7,
zoom: 11,
maxZoom: 16,
pitch: 0,
bearing: 0
};
}
render() {
const {viewport, maleColor, femaleColor, data, radius} = this.props;
if (!data) {
return null;
}
const layer = new ScatterplotLayer({
id: 'scatter-plot',
data,
radiusScale: radius,
radiusMinPixels: 0.25,
getPosition: d => [d[0], d[1], 0],
getColor: d => d[2] === 1 ? maleColor : femaleColor,
getRadius: d => 1,
updateTriggers: {
getColor: {c1: maleColor, c2: femaleColor}
}
});
return (
<DeckGL {...viewport} layers={ [layer] } />
);
}
}