简体   繁体   English

Google Maps API未正确加载

[英]Google maps API not loading properly

I am trying to use google maps JS API v3 in one of my projects everything was working fine until day before yesterday, then suddenly it stopped working when i tried to debug using console it showed that the url for loading map script main.js was failing 我试图在我的一个项目中使用google maps JS API v3一切正常,直到前天,然后突然它停止工作,当我尝试使用控制台调试它显示加载地图脚本main.jsurl失败

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
      html { height: 100% }
      body { height: 100%; margin: 0; padding: 0 }
      #map-canvas { height: 100% }
    </style>
    <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key={API_KEY}&sensor=true">
    </script>
    <script type="text/javascript">
      function initialize() {
        var mapOptions = {
          center: new google.maps.LatLng(-34.397, 150.644),
          zoom: 8
        };
        var map = new google.maps.Map(document.getElementById("map-canvas"),
            mapOptions);
      }
      google.maps.event.addDomListener(window, 'load', initialize);
    </script>
  </head>
  <body>
    <div id="map-canvas"/>
  </body>
</html>

I have used a real API key in place of {API_KEY} 我使用了真正的API密钥来代替{API_KEY}

How can I achieve my objective? 我怎样才能实现目标?

I pasted your code into a file named test.html, inserted a valid api key and tested the following browsers in MAC OS X 10.9: 我将您的代码粘贴到名为test.html的文件中,插入了有效的API密钥并在MAC OS X 10.9中测试了以下浏览器:

  • Safari 苹果浏览器
  • Chrome
  • Firefox 火狐

It works in all these browser without any error. 它适用于所有这些浏览器,没有任何错误。 Please check the following: 请检查以下内容:

  • Validation period of your api key api密钥的验证期
  • invisible characters 看不见的角色

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM