forked from sidx1024/deck.gl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap-controller.js
More file actions
47 lines (39 loc) · 1.02 KB
/
map-controller.js
File metadata and controls
47 lines (39 loc) · 1.02 KB
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
import {PureComponent, createElement} from 'react';
import MapControllerJS from '../core/pure-js/map-controller-js';
export default class MapController extends PureComponent {
constructor(props) {
super(props);
this.controller = null;
}
componentDidMount() {
this.controller = new MapControllerJS(
Object.assign({}, this.props, {canvas: this.eventCanvas})
);
}
componentWillUpdate(nextProps) {
this.controller.setProps(nextProps);
}
componentWillUnmount() {
this.controller.finalize();
}
render() {
const {width, height} = this.props;
const eventCanvasStyle = {
width,
height,
position: 'relative'
};
return createElement(
'div',
{
key: 'map-controls',
ref: c => (this.eventCanvas = c),
style: eventCanvasStyle
},
this.props.children
);
}
}
MapController.displayName = 'MapController';
MapController.propTypes = MapControllerJS.propTypes;
MapController.defaultProps = MapControllerJS.defaultProps;