Skip to content

Commit

Permalink
feat(StreetViewPanorama): update context for children
Browse files Browse the repository at this point in the history
This allows Marker and OverlayView to be attached to the StreetViewPanorama
  • Loading branch information
novascreen authored and Thomas Hermann committed Jun 1, 2017
1 parent e75c936 commit eb86d7e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/basics/StreetViewPanoramaExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const StreetViewPanoramaExampleGoogleMap = withGoogleMap(props => (
* At this point the `GoogleMap` wrapper and `withGoogleMap` HOC become optional, so you can either render map and StreetView
* at the same time, or just the StreetView on its own
* <StreetViewPanorama
* element={<div />}
* element={<div style={{ width: `100%`, height: `100%` }} />}
* defaultPosition={coordinates}
* visible
* />
Expand Down
22 changes: 17 additions & 5 deletions src/lib/StreetViewPanorama.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export default _.flowRight(
[MAP]: PropTypes.object,
},

childContextTypes: {
[MAP]: PropTypes.object,
},

getInitialOptions() {
return collectUncontrolledAndControlledProps(
defaultUncontrolledPropTypes,
Expand All @@ -131,6 +135,12 @@ export default _.flowRight(
);
},

getChildContext() {
return {
[MAP]: this.state[STREET_VIEW_PANORAMA],
};
},

getInitialState() {
// https://developers.google.com/maps/documentation/javascript/3.exp/reference#StreetViewPanorama
let streetViewPanorama;
Expand Down Expand Up @@ -167,11 +177,13 @@ export default _.flowRight(
render() {
if (this.props.element) {
return (
React.cloneElement(this.props.element, {
ref: this.handleComponentMount,
},
));
React.cloneElement(
this.props.element,
{ ref: this.handleComponentMount },
this.props.children,
)
);
}
return false;
return <div>{this.props.children}</div>;
},
});

0 comments on commit eb86d7e

Please sign in to comment.