我正在尝试将Google Maps API与直接在Google Maps平台中创建的新图层一起使用,并导出为.kml文件。使用的指南是Google Developer's门户网站上的主要指南。
但是,似乎KML文件无法正确加载。 http://1c.1contact.ch/mandats/map1.html
连接和加载地图的代码如下(它改编自https://developers.google.com/maps/documentation/javascript/kmllayer):
<script>
var map;
var src = 'http://1c.1contact.ch/file/2573/GE.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: 'terrain'
});
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>
实现这个.KML用法的正确方法是什么?
祝福,