kml 未在 ec2 上加载

kml not loading on ec2

我遇到了类似的问题 post 指的是: KML layer problems in Google Maps Javascript API v3

托管在我的 ec2 实例上时,我的 kml 文件未加载。 当它托管在我的 google 驱动器上时,它可以正常工作。 我的 ec2 端口 80 对所有人开放,我不会用 iptables 阻止任何东西。

这是我的 html:

<!DOCTYPE html>
<html>
  <head>
    <style>
       #map {
        height: 600px;
        width: 100%;
       }
    </style>
  </head>
  <body>
    <h3>My Google Maps Demo</h3>
    <div id="map"></div>
    <script>
      var src = "http://{my host}/locations/test.kml";
       var map;

      function initMap() {
        var uluru = {lat: -25.363, lng: 131.044};
        map = new google.maps.Map(document.getElementById('map'), {
          zoom: 4,
          center: uluru
        });        
        loadKmlLayer(src, map);
      }
      function loadKmlLayer(src, map) {
        var kmlLayer = new google.maps.KmlLayer(src, {
          suppressInfoWindows: true,
          preserveViewport: false,
          map: map
        });
      }
    </script>
    <script async defer
    src="https://maps.googleapis.com/maps/api/js?key=MY-API-KEY&callback=initMap">
    </script>
  </body>
</html>

有什么解决办法吗?

按照@geocodezip 的建议,将文件扩展名从 .kml 更改为 .xml 最终解决了这个问题