Skip to content

Commit

Permalink
feat(Map): setOptions when componentDidUpdate
Browse files Browse the repository at this point in the history
  • Loading branch information
tomchentw committed Oct 25, 2014
1 parent 80110a2 commit 8d07bd3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 5 additions & 1 deletion client/scripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ var Body = React.createClass({

_handle_marker_click () {
console.log("_handle_marker_click");
this.setState({
zoom: (this.state.zoom || this.props.zoom)+1
});
},

_render (props, state) {
console.log('render', state);
return <div>
<Map center={props.center}
zoom={props.zoom}
zoom={state.zoom || props.zoom}
mapTypeId={props.mapTypeId}
onClick={this._handle_map_click} />
<Marker position={props.center}
Expand Down
7 changes: 5 additions & 2 deletions src/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ module.exports = React.createClass({
componentDidUpdate () {
var {context} = this;
if (!context.getApi()) return;
if (context.hasMap()) return;
this.add_listeners(this._init_map());
if (context.hasMap()) {
this.context.getMap().setOptions(this.props);
} else {
this.add_listeners(this._init_map());
}
},

componentWillUnmount () {
Expand Down

0 comments on commit 8d07bd3

Please sign in to comment.