Google Map React
HTML
<script src="http://fb.me/JSXTransformer-0.10.0.js"></script>
<script src="http://fb.me/react-with-addons-0.10.0.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
<div id="root">
</div>
CSS
.map-gic {
height: 500px;
width: 500px
}
body{
width: 500px;
height: 500px;
}
Babel + JSX
// /**
// * Created by mobileheo on 2017-03-22.
// */
import React, { Component } from 'react';
import GoogleMapReact from 'google-map-react';
const AnyReactComponent = ({ text }) => (
<div style={{
position: 'relative', color: 'white', background: 'red',
height: 40, width: 60, top: -20, left: -30,
}}>
{text}
</div>
);
class SimpleMap extends React.Component {
static defaultProps = {
center: {lat: 59.95, lng: 30.33},
zoom: 11
};
render() {
return (
<GoogleMapReact
defaultCenter={this.props.center}
defaultZoom={this.props.zoom}
>
<AnyReactComponent
lat={59.955413}
lng={30.337844}
text={'Kreyser Avrora'}
/>
</GoogleMapReact>
);
}
}
ReactDOM.render(
<div style={{width: '100%', height: '400px'}}>
<SimpleMap/>
</div>,
document.getElementById('root')
);