From 746af8dcec05ec6227562258d0896f4a89054077 Mon Sep 17 00:00:00 2001 From: Yuri Dogandjiev Date: Sun, 24 Jan 2016 00:11:41 -0800 Subject: [PATCH] feat(KmlLayer): add new KmlLayer component --- src/KmlLayer.js | 68 +++++++++++++++++++++++ src/creators/KmlLayerCreator.js | 86 +++++++++++++++++++++++++++++ src/eventLists/KmlLayerEventList.js | 7 +++ src/index.js | 1 + 4 files changed, 162 insertions(+) create mode 100644 src/KmlLayer.js create mode 100644 src/creators/KmlLayerCreator.js create mode 100644 src/eventLists/KmlLayerEventList.js diff --git a/src/KmlLayer.js b/src/KmlLayer.js new file mode 100644 index 00000000..0292d6a9 --- /dev/null +++ b/src/KmlLayer.js @@ -0,0 +1,68 @@ +import { + default as React, + Component, +} from "react"; + +import { + default as canUseDOM, +} from "can-use-dom"; + +import { + default as KmlLayerCreator, + kmlLayerDefaultPropTypes, + kmlLayerControlledPropTypes, + kmlLayerEventPropTypes, +} from "./creators/KmlLayerCreator"; + +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, + } + + // 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() { + if (!canUseDOM) { + return; + } + const kmlLayer = KmlLayerCreator._createKmlLayer(this.props); + + this.setState({ kmlLayer }); + } + + render() { + if (this.state.kmlLayer) { + return ( + + {this.props.children} + + ); + } else { + return (