Skip to content

Instantly share code, notes, and snippets.

@metalmatze
Created June 16, 2015 21:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metalmatze/48e2db156c627ec2b59f to your computer and use it in GitHub Desktop.
Save metalmatze/48e2db156c627ec2b59f to your computer and use it in GitHub Desktop.
render() {
return (
<GoogleMaps
containerProps={{
style: {
height: "100%"
}
}}
ref="map"
disableDefaultUI={true}
googleMapsApi={window.google.maps}
zoom={this.state.zoomLevel}
center={this.state.center}
onZoomChanged={this.handleZoomChanged}
onCenterChanged={this.handleCenterChanged}>
{this.state.locations.map(this.renderMarker)}
</GoogleMaps>
)
}
handleZoomChanged() {
const zoomLevel = this.refs.map.getZoom();
if (this.state.zoomLevel !== zoomLevel) {
this.setState({
zoomLevel: zoomLevel
});
}
}
handleCenterChanged() {
const center = this.refs.map.getCenter();
if (!this.state.center.equals(center)) {
this.setState({
center: center
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment