/
KmlLayer.js
81 lines (66 loc) · 2.05 KB
/
KmlLayer.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import {
default as React,
Component,
PropTypes,
} from "react";
import {
default as canUseDOM,
} from "can-use-dom";
import {
default as KmlLayerCreator,
kmlLayerDefaultPropTypes,
kmlLayerControlledPropTypes,
kmlLayerEventPropTypes,
} from "./creators/KmlLayerCreator";
import { default as GoogleMapHolder } from "./creators/GoogleMapHolder";
export default class KmlLayer extends Component {
static propTypes = {
// Uncontrolled default[props] - used only in componentDidMount
...kmlLayerDefaultPropTypes,
// Controlled [props] - used in componentDidMount/componentDidUpdate
...kmlLayerControlledPropTypes,
// Event [onEventName]
...kmlLayerEventPropTypes,
}
static contextTypes = {
mapHolderRef: PropTypes.instanceOf(GoogleMapHolder),
}
// Public APIs
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#KmlLayer
//
// [].map.call($0.querySelectorAll("tr>td>code"), function(it){ return it.textContent; }).filter(function(it){ return it.match(/^get/) && !it.match(/Map$/); })
getDefaultViewport() { return this.state.kmlLayer.getDefaultViewport(); }
getMetadata() { return this.state.kmlLayer.getMetadata(); }
getStatus() { return this.state.kmlLayer.getStatus(); }
getUrl() { return this.state.kmlLayer.getUrl(); }
getZIndex() { return this.state.marker.getZIndex(); }
// END - Public APIs
//
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#KmlLayer
state = {
}
componentWillMount() {
const { mapHolderRef } = this.context;
if (!canUseDOM) {
return;
}
const kmlLayer = KmlLayerCreator._createKmlLayer({
...this.props,
mapHolderRef,
});
this.setState({ kmlLayer });
}
render() {
const { mapHolderRef } = this.context;
if (this.state.kmlLayer) {
return (
<KmlLayerCreator mapHolderRef={mapHolderRef} kmlLayer={this.state.kmlLayer} {...this.props}>
{this.props.children}
</KmlLayerCreator>
);
} else {
return (<noscript />);
}
}
}