Skip to content

Instantly share code, notes, and snippets.

@MicheleBertoli
Created October 10, 2016 10:50
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 MicheleBertoli/a42095f0cc6e31e5f2d0dfda3bc7dbcd to your computer and use it in GitHub Desktop.
Save MicheleBertoli/a42095f0cc6e31e5f2d0dfda3bc7dbcd to your computer and use it in GitHub Desktop.
Idle
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { Gmaps } from 'react-gmaps';
const App = React.createClass({
getInitialState() {
return {
loaded: false,
};
},
handleIdle() {
if (!this.state.loaded) {
console.log('do something only the first time the map is loaded');
this.setState({
loaded: true,
});
}
},
render() {
return (
<div style={{ visibility: !this.state.loaded && 'hidden' }}>
<Gmaps
height={300}
lat={51.5258541}
lng={-0.08040660000006028}
onIdle={this.handleIdle}
width={400}
zoom={12}
/>
</div>
);
}
});
ReactDOM.render(<App />, document.getElementById('gmaps'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment