簡體   English   中英

使用Google Maps API時地圖不顯示

[英]Map not showing when using Google Maps API

我正在嘗試使用Google Maps API來顯示一張地圖。 我正在使用Javascript。

它應該是一個頁面,其中包含一個標題,並且在標題下方有一個地圖。 我最近注冊了Google Maps API,所以不確定該API密鑰是否需要花費一定的時間才能激活。 我還有其他CSS文件和一個googlemaps.js文件,其中還沒有任何內容。

這是我的代碼。 任何想法為什么它不起作用?

<!doctype html>
<html>
<head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, intial-scale=1.0;'>
    <title>API(s)</title>
    <link rel='stylesheet' href='styles/semantic.min.css'>
    <link rel='stylesheet' href='styles/main.css'>

</head>

<body>

    <div class="ui two column centered stackable grid container">
        <div class="column">
            <h1 class="goog-header">Location Based Image Search</h1>
        </div>
    </div>

    <div class="ui one column stackable grid container js-images-container">
        <div class="column">
            <div id="map"></div>
        </div>
    </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="https://maps.googleapis.com/maps/api/js?key=AIzaSyCXTmorapOu1WquB3VlsLrckhE45Bgfrfw&callback=initMap" async defer></script>

<script src='javascript/googlemaps.js'></script>    
</body>
</html>

嘗試將地圖DIV更改為:

<div id="map" style="width:800px;height:600px"></div>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM