0
這裏是我的代碼:KML層問題
<html><head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map-canvas { height: 500px; width: 500px; }
</style>
<title>Map Your Reps</title>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api /js?key={key}"></script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(-34, 92),
zoom: 7
};
var map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var kmlUrl = "http://{HOST}/kml/file.kml";
var kmlOptions = {
suppressInfoWindows: true,
preserveViewport: false,
map: map
};
var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<h1>Map</h1>
<div id="map-canvas"/>
</body></html>
出於某種原因,.KML文件,雖然公開訪問,是沒有得到通過API加載。
https://maps.googleapis.com/maps/api/js/KmlOverlayService.GetOverlays?1shttp%3A%2F%2F{HOST}%2Fkml%2Ffile.kml&callback=_xdc_._9dx071&token=97074
的響應是: /**/_xdc_._9dx071 && _xdc_._9dx071([0,null,null,null,null,null,3,[["client","2"]]])
當我加載其他KML文件,這種數據結構表示數據
我的在Chrome開發工具以下請求中的網絡標籤通知從文件中。
一些事實:
- 我的HTML文件和我的KML文件都可以在Amazon EC2實例和公開訪問......沒有密碼,HTTPS,或其他棘手的業務
- 我的KML文件不壓縮...這是現實生活中的bonafide KML文件
- 我的KML文件驗證上kmlvalidator.com
- 我的KML是709K的大小和包括多邊形生成
- 任何錯誤消息,並沒有什麼APPE ars在地圖上......除了地圖本身。
我很感激任何幫助,我可以弄清楚爲什麼這個KML層沒有加載。
謝謝!
什麼是[status](https://developers.google.com/maps/documentation/javascript/reference#KmlLayerStatus)?什麼是KML的網址? – geocodezip
我遇到同樣的問題,以前的代碼已停止工作,沒有任何錯誤。我也收到一個迴應,其中包含空值。 – user2218399
這個問題不應該被低估,它是完全有效的。 –