【问题标题】:This page didn't load Google Maps correctly. See the JavaScript console for technical details.before that showed map in 2s此页面未正确加载 Google 地图。有关技术详情,请参阅 JavaScript 控制台。在 2 秒内显示地图之前
【发布时间】:2019-10-12 15:32:09
【问题描述】:

我正在使用来自谷歌地图 API 的代码并输入 API 密钥,但仍然收到上述错误

@{
    Layout = null;
}
<style>
   #map {
        height: 400px;
        width: 200px;
}
</style>
<div id="map"></div>
<script>
    function initMap() {
       var map = new google.maps.Map(document.getElementById('map'), {
       center: { lat: 10.523900, lng: 76.212250 },
       zoom: 8
        });
      }
</script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAi6Ztik8PTvZFBFieP0k7aVWGMdNGHJ9c&callback=initMap"></script>

【问题讨论】:

标签: javascript asp.net-mvc


【解决方案1】:

更新:看起来您的代码没问题。我认为这是您在 Google 开发者控制台中配置网站设置的方式的问题 - 请查看 SO post

这需要确保您正确输入域通配符 (http://www.example.com/*) 并启用所需的 API (Maps JavaScript API)。

【讨论】:

  • 更新了我的答案。
  • 是的,我解决了这个错误。但现在显示“计费帐户”错误。有什么方法可以免费获取api key?
猜你喜欢
  • 2016-09-21
  • 1970-01-01
  • 2020-06-23
  • 2016-12-28
  • 2012-07-20
  • 2019-12-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多