当前位置: 代码迷 >> JavaScript >> 由于错误代码:InvalidKeyOrUnauthorizedURLMapError,提供的Google API密钥无效
  详细解决方案

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

热度:65   发布时间:2023-06-05 11:50:42.0

我遵循了有关如何为浏览器生成API密钥的Google教程,但是由于密钥无效错误,我无法加载地图。

在我的情况下,没有发布到相关问题的解决方案。

这是我的代码:

    <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密钥,然后尝试。

如果使用,请尝试-

    <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>
  相关解决方案