【发布时间】:2019-01-12 02:33:27
【问题描述】:
我目前正在使用react-google-map 让 Google Map 在我的 React 项目中运行,这是我的 Map 组件:
import React from 'react'
import { compose, withProps, lifecycle } from 'recompose'
import { withScriptjs, withGoogleMap, GoogleMap } from 'react-google-maps'
import MapStyle from '../../../api/mapStyle'
const Map = ({ children }) => {
return (
<GoogleMap
defaultZoom={15}
defaultCenter={{ lat: 35.6840299, lng: 51.3861187 }}
>
{children}
</GoogleMap>
)
}
export default compose(
withProps({
googleMapURL: "https://maps.googleapis.com/maps/api/js?key=MY_KEY_HERE",
loadingElement: <div style={{ height: `100%` }} />,
containerElement: <div className='map' style={{ height: `100vh` }} />,
mapElement: <div style={{ height: `100%` }} />
}),
withScriptjs,
withGoogleMap,
)(Map)
如您所见,正如react-google-map DOC 所说,这里没有什么特别的!
昨天我刚开始建地图,和往常一样,我去我的谷歌控制台得到了一个钥匙,然后我把它放在链接的MY_KEY_HERE部分,直到今天早上它都工作得很好,今天我正在苦苦挣扎:
您已超出此 API 的请求配额
不是:
您已超出此 API 的每日请求配额
如下:
我在 Google 上进行了搜索,发现了 this 和 this 和 this 以及许多其他问题,但我找不到任何正确答案。
我尝试了什么?
- 我在控制台中创建了几个其他键来解决这个问题,但没有解决,我得到了同样的
You have exceeded your request quota for this API错误 - 我使用我在 Google 上的另一个帐户来解决此问题,我刚刚登录并转到控制台平台并再次生成了一个密钥,但我仍然收到该错误?
- 即使在 codeSandBox.io 中尝试,我仍然遇到同样的错误
我对这个问题很困惑,我该如何解决?
【问题讨论】:
-
错误信息中的链接是什么意思?
-
也许你需要明确地说要使用 API 的
v3。"https://maps.googleapis.com/maps/api/js?v=3.exp&key=MY_KEY_HERE" -
让我试试....
-
不,仍然出现同样的错误......在我的项目中也是一个代码框
标签: javascript reactjs google-maps google-maps-api-3