Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/map on load #156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/GoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,17 @@ var GoogleMap = (function (_Component) {
var containerTagName = _props.containerTagName;
var containerProps = _props.containerProps;
var children = _props.children;
var onLoad = _props.onLoad;

var mapProps = _objectWithoutProperties(_props, ["containerTagName", "containerProps", "children"]);
var mapProps = _objectWithoutProperties(_props, ["containerTagName", "containerProps", "children", "onLoad"]);

// TODO: support asynchronous load of google.maps API at this level.
//
// Create google.maps.Map instance so that dom is initialized before
// React's children creators.
//
var map = _creatorsGoogleMapHolder2["default"]._createMap(domEl, mapProps);
onLoad ? onLoad(map) : null;
this.setState({ map: map });
}
}, {
Expand Down Expand Up @@ -178,7 +180,8 @@ var GoogleMap = (function (_Component) {
key: "propTypes",
value: _extends({
containerTagName: _react.PropTypes.string.isRequired,
containerProps: _react.PropTypes.object.isRequired
containerProps: _react.PropTypes.object.isRequired,
onLoad: _react.PropTypes.func
}, _creatorsGoogleMapHolder.mapDefaultPropTypes, _creatorsGoogleMapHolder.mapControlledPropTypes, _creatorsGoogleMapHolder.mapEventPropTypes),
enumerable: true
}, {
Expand Down
4 changes: 3 additions & 1 deletion src/GoogleMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default class GoogleMap extends Component {
static propTypes = {
containerTagName: PropTypes.string.isRequired,
containerProps: PropTypes.object.isRequired,
onLoad: PropTypes.func,
// Uncontrolled default[props] - used only in componentDidMount
...mapDefaultPropTypes,
// Controlled [props] - used in componentDidMount/componentDidUpdate
Expand Down Expand Up @@ -80,13 +81,14 @@ export default class GoogleMap extends Component {

componentDidMount () {
const domEl = findDOMNode(this);
const {containerTagName, containerProps, children, ...mapProps} = this.props;
const {containerTagName, containerProps, children, onLoad, ...mapProps} = this.props;
// TODO: support asynchronous load of google.maps API at this level.
//
// Create google.maps.Map instance so that dom is initialized before
// React's children creators.
//
const map = GoogleMapHolder._createMap(domEl, mapProps);
onLoad ? onLoad(map) : null
this.setState({ map });
}

Expand Down