目前我正在尝试在反应中渲染简单的地图。我尝试过的一切,但都是静脉。现在我使用 google-maps-react 来渲染 google map 并包含它的库,但我仍然得到 google is undefined 我不知道为什么。这是我的代码
// External Dependencies
import React, { Component } from 'react';
import { withGoogleMap, GoogleMap , GoogleMapLoader,Marker} from 'react-google-maps';
// Internal Dependencies
import './style.css';
class HelloWorld extends Component {
static slug = 'nel_hello_world';
render() {
var google = window.google;
const GoogleMapExample = withGoogleMap(props => (
<GoogleMap
defaultCenter = { { lat: 40.756795, lng: -73.954298 } }
defaultZoom = { 13 }
>
</GoogleMap>
));
// const Content = this.props.content;
return (
<div>
<GoogleMapExample
containerElement={<div style={{ height: `500px`, width: '500px' }} /> }
mapElement={ <div style={{ height: `100%` }} /> }
/>
</div>
);
}
}
export default HelloWorld;
有什么建议么 ?? ?