使用Geoxml3在Google地图上加载KML图层 [英] Loading KML layer on Google map using Geoxml3
本文介绍了使用Geoxml3在Google地图上加载KML图层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用Geoxml3在googlemap上加载kmlfile,googlemap已加载,但图层不显示,我不知道我的代码出了什么问题,任何人都可以帮忙?
I want to use Geoxml3 to load a kmlfile on googlemap, the googlemap is loaded but the layer is not shown, i don't know what is wrong with my code, can anyone help?
<script type="text/javascript">
jQuery(document).ready(function () {
var myOptions = {
center: new google.maps.LatLng(39.397, -100.644),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var geoXml = new geoXML3.parser({
map: map,
singleInfoWindow: true,
afterParse: useTheData
});
geoXml.parse('KML_Samples.kml');
});
function useTheData(doc) {
// Geodata handling goes here, using JSON properties of the doc object
for (var i = 0; i < doc[0].markers.length; i++) {
console.log(doc[0].markers[i].title);
jQuery('#map_text').append(doc[0].markers[i].title + ', ');
}
};
</script>
</head>
<body >
<form id="form1">
<div id="map_canvas" style="width:600px;height:500px;"></div>
<div id="map_text"></div>
</form>
</body>
</html>
推荐答案
您的代码至少与您发布的作品对我来说很好。
Your code, at least as much as you posted works fine for me.
这是工作例子
这篇关于使用Geoxml3在Google地图上加载KML图层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文