Created
August 13, 2015 09:48
-
-
Save MicheleBertoli/85bb8de4504484620315 to your computer and use it in GitHub Desktop.
Gmaps Circle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {Gmaps, Circle} from 'react-gmaps'; | |
const coords = { | |
lat: 51.5258541, | |
lng: -0.08040660000006028 | |
} | |
const App = React.createClass({ | |
getInitialState() { | |
return { | |
radius: 100 | |
} | |
}, | |
handleClick() { | |
const {radius} = this.state; | |
this.setState({ | |
radius: radius * 2 | |
}); | |
}, | |
render() { | |
const {radius} = this.state; | |
return ( | |
<div> | |
<Gmaps | |
width={'400px'} | |
height={'300px'} | |
lat={coords.lat} | |
lng={coords.lng} | |
zoom={12}> | |
<Circle | |
strokeColor={'#F44336'} | |
strokeOpacity={0.8} | |
strokeWeight={2} | |
fillColor={'#F44336'} | |
fillOpacity={0.35} | |
radius={radius} | |
lat={coords.lat} | |
lng={coords.lng} /> | |
</Gmaps> | |
<button onClick={this.handleClick}> | |
Click me! | |
</button> | |
</div> | |
); | |
} | |
}); | |
React.render(<App />, document.getElementById('gmaps')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment