GoogleマップにKMLを表示しようとしています。マップは完全に読み込まれますが、KMLはまったく表示されません。また、コンソールにエラーメッセージが表示されません。地図上にKMLレイヤーが表示されない
gadm.orgから.kmzファイルをダウンロードし、解凍して.kmlファイルを抽出しました。
私のコードと私のKMLのURLはここにあります。そのKMLとINVALID_DOCUMENT(link): http://locallocal.com/endline/mex2.kml
<script>
var map;
var src = 'http://locallocal.com/endline/mex2.kml';
/**
* Initializes the map and calls the function that loads the KML layer.
*/
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: new google.maps.LatLng(-19.257753, 146.823688),
zoom: 2,
mapTypeId: 'roadmap'
});
loadKmlLayer(src, map);
}
/**
* Adds a KMLLayer based on the URL passed. Clicking on a marker
* results in the balloon content being loaded into the right-hand div.
* @param {string} src A URL for a KML file.
*/
function loadKmlLayer(src, map) {
var kmlLayer = new google.maps.KmlLayer(src, {
suppressInfoWindows: true,
preserveViewport: false,
map: map
});
google.maps.event.addListener(kmlLayer, 'click', function(event) {
var content = event.featureData.infoWindowHtml;
var testimonial = document.getElementById('capture');
testimonial.innerHTML = content;
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=[MYKEY]&callback=initMap">
関連する質問:[Googleマップで動作する郡KMLデータ](http://stackoverflow.com/questions/35347003/county-kml-data-that-works-with-google-maps) – geocodezip