【问题标题】:Google Maps: Doesn't displays on localhost谷歌地图:不显示在本地主机上
【发布时间】:2014-11-06 20:36:52
【问题描述】:

我正在尝试将 Google 地图集成到我的应用中。我已经阅读了 API v3 文档,生成了 API 密钥,但地图每小时加载大约 1 次。其他时区前图为空

我在 HTML 标头中用于地图渲染的这段代码:

<script src = "https://maps.googleapis.com/maps/api/js?key=HERE-IS-MY-UNIQUE-KEY"></script>
<script>
    var geocoder;
    var map;
    function initialize() {
      geocoder = new google.maps.Geocoder();
      var latlng = new google.maps.LatLng(51.5073509,-0.1277583);
      var mapOptions = {
        zoom: 10,
        center: latlng
      }
      map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    }

    google.maps.event.addDomListener(window, 'load', initialize);
</script>

这里是 HTML 的代码 sn-p:

...
                <div class="form-group">
                    <div class="col-sm-8">
                        <div id="map-canvas" style="height:200px;width:400px;"></div>
                    </div>
                </div>
...

这里有什么问题?为什么地图不能在常规基础上渲染?

【问题讨论】:

  • 光看很难说,但是把Geocoder的零件拿出来就行了吗?您是否收到任何错误消息或任何东西?如果您能提供尽可能多的关于您的问题的信息,那就太好了……“帮我修复我的代码”问题通常不会在这里得到很好的对待。
  • 删除密钥后会发生什么?

标签: google-maps google-maps-api-3


【解决方案1】:

只需将js?=API_KEY 部分更改为js?v=3.exp 这应该可以解决您的问题。

编辑 26-06-2016:无钥匙访问不再可用。感谢 VikVik 的更新。

【讨论】:

猜你喜欢
  • 2015-08-10
  • 2020-07-25
  • 2014-08-05
  • 2013-05-26
  • 1970-01-01
  • 2016-04-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多