Skip to content

Commit

Permalink
feat(Declarative Bounds) specify map bounds via props
Browse files Browse the repository at this point in the history
  • Loading branch information
Pete Browne committed May 30, 2015
1 parent 3433bff commit a4b48a1
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/GoogleMaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,15 @@ class GoogleMaps extends EventComponent {
}
// googleMapsApi can be async loaded
/*eslint-disable no-unused-vars */
const {containerProps, googleMapsApi, ...googleMapsConfig} = props;
const {containerProps, googleMapsApi, bounds, ...googleMapsConfig} = props;
/*eslint-enable no-unused-vars */
var {instance} = this.state;

if (bounds) {
delete googleMapsConfig.zoom;
delete googleMapsConfig.center;
}

if (instance) {
instance.setOptions(googleMapsConfig);
} else {
Expand All @@ -71,6 +76,11 @@ class GoogleMaps extends EventComponent {

this.setState({instance});
}

if (bounds) {
instance.fitBounds(bounds);
}

return instance;
}

Expand Down Expand Up @@ -120,6 +130,7 @@ class GoogleMaps extends EventComponent {
GoogleMaps.propTypes = {
...EventComponent.propTypes,
containerProps: PropTypes.object.isRequired,
bounds: React.PropTypes.object
};

GoogleMaps._registerEvents = createRegisterEvents(
Expand Down

0 comments on commit a4b48a1

Please sign in to comment.