Google Maps API v3: Gray Box, no map

后端 未结 14 758
离开以前
离开以前 2020-12-06 09:20

As part of a much bigger project, we\'re trying to get a Map on a site using Google\'s Map API v3. I have followed the simplest steps that Google has laid out, I\'ve tried c

相关标签:
14条回答
  • 2020-12-06 09:56

    In my case (version is 3.30 when submitting this), it was because the div id MUST be "map"

    <div id="map"></div>
    ...
    document.getElementById("map")
    
    0 讨论(0)
  • 2020-12-06 09:59

    Also beware of having an invalid latitude or longitude value for the map center or your markers. For example, this fiddle shows the Grey Map Of Death because the map center is at latitude 131.044 which is invalid (not from +90:-90).

    function initMap() {
      var uluru = {lat: 131.044, lng: -25.363};
      var map = new google.maps.Map(document.getElementById('map'), {
        zoom: 4,
        center: uluru
      });
      var marker = new google.maps.Marker({
        position: uluru,
        map: map
      });
    }
    
    0 讨论(0)
提交回复
热议问题