Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google Maps Javascript API返回map not found错误的简单示例_Javascript_Google Maps - Fatal编程技术网

Google Maps Javascript API返回map not found错误的简单示例

Google Maps Javascript API返回map not found错误的简单示例,javascript,google-maps,Javascript,Google Maps,我将上的简单示例复制到一个空白网页中。我所做的唯一更改是用我的google API密钥替换这行中的\u API\u密钥: <script src = "https://maps.googleapis.com/maps/api/jskey=YOUR_API_KEY&callback=initMap" async defer> </script> 当我试图打开此页面时,我收到一条Oops,出现了一些错误消息。 Google Maps平台API检查器表示成功使用了A

我将上的简单示例复制到一个空白网页中。我所做的唯一更改是用我的google API密钥替换这行中的\u API\u密钥:

<script src = 
"https://maps.googleapis.com/maps/api/jskey=YOUR_API_KEY&callback=initMap"
async defer>
</script>
当我试图打开此页面时,我收到一条Oops,出现了一些错误消息。 Google Maps平台API检查器表示成功使用了API密钥,但消息的信息部分表示在加载页面的2秒内找不到可见的Google地图。 我还尝试了一种变体,将上面引用的脚本行中的https:更改为http:,但结果是一样的。 任何关于我可能做错什么的建议都将不胜感激

作为.html文件的页面的完整代码为:

<!DOCTYPE html>
<html>
  <head>
    <title>Simple Map</title>
    <meta name="viewport" content="initial-scale=1.0">
    <meta charset="utf-8">
    <style>
      /* Always set the map height explicitly to define the size of the div
       * element that contains the map. */
      #map {
        height: 100%;
      }
      /* Optional: Makes the sample page fill the window. */
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
    </style>
  </head>
  <body>
    <div id="map"></div>
    <script>
      var map;
      function initMap() {
        map = new google.maps.Map(document.getElementById('map'), {
          center: {lat: -34.397, lng: 150.644},
          zoom: 8
        });
      }
    </script>
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCa5LZ-wqIoBLPk0XcVgMn12fi01iYHS6I&callback=initMap"
    async defer></script>
  </body>
</html>

当我使用javascript控制台时,我发现我遇到了一个referer not authorized错误,尽管事实上我已经为所讨论的URL授权了API。通过搜索堆栈溢出中的错误,我发现了一些关于这个问题的帖子,并建议尝试重新生成API。我这样做了,问题就解决了。

你说的那句话没有出现。请修理。