【发布时间】:2016-03-09 06:32:39
【问题描述】:
我必须在浏览器中加载 KML 文件。我已经加载了简单的 KML 文件,它运行良好,但是当我上传带有多个图像文件夹的 KML 文件时,它无法正确加载。 使用的行代码:-
<div id="map_canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false>"></script>
<script>
var mylocation = {
'latitude': -45.2427303,
'longitude': 115.0639984
};
var map;
function initialize()
{
var myLatlng = new google.maps.LatLng( mylocation.latitude, mylocation.longitude );
var mapOptions = {
zoom: 5,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
var kmlPath = '<?php echo urldecode($file_name)?>';
var urlSuffix = (new Date).getTime().toString();
var layer = new google.maps.KmlLayer(kmlPath + '?' + urlSuffix );
layer.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
【问题讨论】:
-
KML 文件是什么样的?它有多大?是valid吗?
kmlPath是完全限定的 URL 吗?请提供一个 Minimal, Complete, Tested and Readable example 来证明您的问题。
标签: google-maps dictionary kml