Created
November 16, 2015 12:00
-
-
Save MicheleBertoli/2658419a7c65cdc4ad24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ReactDOM from 'react-dom'; | |
import {Gmaps, Marker} from 'react-gmaps'; | |
const coords = { | |
lat: 51.5258541, | |
lng: -0.08040660000006028 | |
}; | |
const App = React.createClass({ | |
getInitialState() { | |
return { | |
lat: coords.lat, | |
lng: coords.lng | |
}; | |
}, | |
onDragEnd(e) { | |
this.setState({ | |
lat: e.latLng.lat(), | |
lng: e.latLng.lng() | |
}); | |
}, | |
render() { | |
return ( | |
<Gmaps | |
width={400} | |
height={400} | |
lat={coords.lat} | |
lng={coords.lng} | |
zoom={12}> | |
<Marker | |
lat={this.state.lat} | |
lng={this.state.lng} | |
draggable={true} | |
onDragEnd={this.onDragEnd} /> | |
</Gmaps> | |
); | |
} | |
}); | |
ReactDOM.render(<App />, document.getElementById('gmaps')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment