reactjs - 谷歌在反应中渲染谷歌地图时未定义
问题描述
目前我正在尝试在反应中渲染简单的地图。我尝试过的一切,但都是静脉。现在我使用 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;
有什么建议么 ?? ?
解决方案
推荐阅读
- r - Pairing columns and making dataframe from wide to long in r
- c# - 使用 LINQ 对列表进行排序或排序并输出到列表框中
- makefile - 检查 makefile 中的 ifort/icc 版本
- go - 使用服务帐户从 Google REST API 获取数据
- powerbi - M 语言 - 除以字段的 MAX()
- c# - Xpath 表达式等于不起作用但大于?
- django - 如何在python中将orderdict转换为json?
- java - 每次执行后更改 @Schduled 注解内的 cron 值
- ios - UITextView 根据 UITableViewCell 中的文本动态宽度
- python - 如何读取行分布在多行的文件?