你必须使用谷歌地图JavaScript API https://developers.google.com/maps/documentation/javascript/reference?hl=es
您必须将google.maps.KmlLayer
附加到地图上。
把API脚本在<head>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
创建这样一个div:
<div id="google-map" class="google-map"></div>
然后,使用这个JS代码</body>
之前。设置您的纬度,经度和KML文件的路径。
<script>
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(YOUR_LAT,YOUR_LNG), //Set your latitude, longitude
zoom: 19,
mapTypeId: google.maps.MapTypeId.SATELLITE,
scrollwheel: false
}
var map = new google.maps.Map(document.getElementById('google-map'), mapOptions); // get the div by id
var ctaLayer = new google.maps.KmlLayer({
url: 'PATH/TO/FILE.kml' // Set the KML file
});
// attach the layer to the map
ctaLayer.setMap(map);
}
// load the map
google.maps.event.addDomListener(window, 'load', initialize);
</script>
你想做什么?以明文形式显示.kml文件的联系人? – Bijan 2014-10-27 23:38:01
我正在尝试将我的KML图层添加到网站上显示的Google地球上。 – MadsterMaddness 2014-10-27 23:39:28
你为什么使用iframe?你可以添加'satellites.kml'作为一个新层。看到[这里](http://stackoverflow.com/questions/17409598/toggle-multiple-kml-kml-layers-in-google-maps-api-v3)如何做别人 – Bijan 2014-10-27 23:42:47