由于错误码:InvalidKeyOrUnauthorizedURLMapError,提供的Google API密钥无效

The provided Google API key is invalid due to Error Code: InvalidKeyOrUnauthorizedURLMapError

本文关键字:Google API 密钥 无效 误码 于错 InvalidKeyOrUnauthorizedURLMapError      更新时间:2023-09-26

我按照谷歌教程如何为浏览器生成API密钥,但由于无效密钥错误,我无法加载地图。

所有相关问题的解决方案都不适合我的情况。

这是我的代码:

    <head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> 
  <title>myTitle</title> 
<script src="https://maps.googleapis.com/maps/api/js?key=MYKEY"
  type="text/javascript"></script>
</head> 

Web控制台日志:

    "ApiNotActivatedMapError: https://developers.google.com/maps/documentation/javascript/tutorial#api_key" main.js line 61 > eval:50:381
Nr/this.j</<() main.js line 61 > eval:50
as</<() main.js line 61 > eval:54
Ar/d() main.js line 61 > eval:43
<anonymous> AuthenticationService.Authenticate:1

您是否使用一些库,如地点库或地理代码?

删除API Key并尝试。

如果使用,则试试-:

    <script src="http://maps.google.com/maps/api/js?sensor=false&libraries=places"></script>

如果不使用,试试-:

    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>