Google maps 如何在浏览器中加载KML文件
我必须在浏览器中加载KML文件。我也加载了简单的KML文件。它工作得很好,但当我上载带有多个图像文件夹的KML文件时,它没有正确加载。 使用的行代码:-Google maps 如何在浏览器中加载KML文件,google-maps,dictionary,kml,Google Maps,Dictionary,Kml,我必须在浏览器中加载KML文件。我也加载了简单的KML文件。它工作得很好,但当我上载带有多个图像文件夹的KML文件时,它没有正确加载。 使用的行代码:- <div id="map_canvas"></div> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false>"></script&g
<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>
Kmlayer在谷歌的服务器端生成地图分幅。因此,多个Kmlayer和fusion tables层有时也不能像您预期的那样工作。 官方文件中没有描述这一点,但这是根据我的经验得出的 我建议您将GeoJSON与数据层一起使用。 数据层生成覆盖标记、多段线等。。。在客户端。 您可以轻松修改生成的覆盖。 看看吧
KML文件是什么样子的?它有多大?它是?kmlPath是完全限定的URL吗?请提供一份说明您的问题的报告。