Javascript Google 地图中的“您已超出此 API 的请求配额”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/51685490/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"You have exceeded your request quota for this API" in Google Map
提问by a_m_dev
I am currently using react-google-mapfor getting Google Map to run in my React project, here is my Map component:
我目前正在使用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)
As you can see this is as what react-google-mapDOC says , nothing so fancy here!
正如你所看到的,这就是react-google-mapDOC 所说的,这里没有什么特别的!
Yesterday I just started to build map, and as normal I went to my Google console and got a key, then I put it on MY_KEY_HEREsection of link , and it worked fine until this morning, today i am struggling with:
昨天我刚刚开始构建地图,像往常一样,我去我的谷歌控制台并拿到了一个钥匙,然后我把它放在MY_KEY_HERE链接的部分,直到今天早上它都运行良好,今天我正在努力:
You have exceeded your request quota for this API
您已超出此 API 的请求配额
Not:
不是:
You have exceeded your daily request quota for this API
您已超出此 API 的每日请求配额
as below:
如下:
I searched Google and I found thisand thisand thisand many many others, but I could not find any proper answer to this problem.
我搜索了谷歌,我找到了这个、这个、这个和许多其他的,但我找不到这个问题的任何正确答案。
What did I try?
我尝试了什么?
- I created a couple of other keys in my console to remove this problem , but it is not solved, I got the same You have exceeded your request quota for this APIerror
- I used another account of mine on Google to resolve this issue and I just logged in and went to console platform and again generated a key, but I still getting that error?
- even by trying it in codeSandBox.io, I still got the same error
- 我在控制台中创建了其他几个键来解决这个问题,但没有解决,我遇到了同样的You have exceeded your request quota for this API错误
- 我在 Google 上使用了我的另一个帐户来解决此问题,我刚刚登录并转到控制台平台并再次生成了一个密钥,但我仍然收到该错误?
- 即使在 codeSandBox.io 中尝试,我仍然遇到相同的错误
I'm really confused about this issue, how should I solve it?
我真的很困惑这个问题,我该如何解决?
采纳答案by Víctor
Check if your project has a billing account associated to it. You can use this Google tool: https://mapsplatformtransition.withgoogle.com/
检查您的项目是否有关联的结算帐号。您可以使用此 Google 工具:https: //mapsplatformtransition.withgoogle.com/
"This project does not have a billing account. You will need to add billing information for this project to continue to use Google Maps Platform. The first $200 of monthly usage is free. You only pay for what you use. You can review rates and access your spending any time in your Google Cloud Platform Console, where you can also set daily quotas to protect against unexpected increases. You can also set billing alerts to receive email notifications when charges reach a preset threshold determined by you."
“此项目没有结算帐户。您需要为此项目添加结算信息才能继续使用 Google Maps Platform。每月前 200 美元的使用费是免费的。您只需为使用的内容付费。您可以查看费率和“您可以随时在 Google Cloud Platform Console 中访问您的支出,您还可以在其中设置每日配额以防止意外增加。您还可以设置账单提醒,以便在费用达到您确定的预设阈值时接收电子邮件通知。”
It will list all your projects using Google Maps and tell you to "Add Billing" if the project status is not "in good shape".
它会列出您使用 Google 地图的所有项目,如果项目状态不是“良好”,它会告诉您“添加账单”。
回答by Akarsh Vijayan
The issue is because you haven't created the billing account for your project.
问题是因为您尚未为您的项目创建结算帐号。
Without billing account by default good maps API will allow only 1 map load per key per day.
默认情况下,如果没有计费帐户,好的地图 API 将只允许每个键每天加载 1 个地图。
You can follow these steps to resolve the issue :
您可以按照以下步骤解决问题:
- Go to Google Cloud Platform Console.
- Enable billing account for your project.
- Select the project that contains the API you want to review.
- From the list of APIs on the Dashboard, click the name of the API.
- Near the top of the page, click Quotas or Usage and set the limit according to your usage.
- 转到谷歌云平台控制台。
- 为您的项目启用结算帐号。
- 选择包含您要的 API 的项目。
- 从仪表板上的 API 列表中,单击 API 的名称。
- 在页面顶部附近,单击配额或使用量并根据您的使用量设置限制。


