-
Notifications
You must be signed in to change notification settings - Fork 939
/
GoogleMapsMixin.js
51 lines (42 loc) · 861 Bytes
/
GoogleMapsMixin.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
"use strict";
var React = require("react/addons");
module.exports = {
getInitialState () {
return {
googleMapsApi: this.props.googleMapsApi,
map: null
};
},
childContextTypes: {
getMap: React.PropTypes.func,
getApi: React.PropTypes.func,
hasMap: React.PropTypes.func,
getRef: React.PropTypes.func,
_set_map: React.PropTypes.func
},
getChildContext () {
return {
getMap: this._get_map,
getApi: this._get_api,
hasMap: this._has_map,
getRef: this._get_ref,
_set_map: this._set_map
};
},
_get_map () {
return this.state.map;
},
_get_api () {
return this.state.googleMapsApi;
},
_has_map () {
return !!this._get_map();
},
_get_ref (key) {
return this.refs[key];
},
_set_map (map) {
this.setState({ map });
return map;
}
};