我想使用 Geoxml3 在 googlemap 上加载 kmlfile,googlemap 已加载但未显示图层,我不知道我的代码有什么问题,谁能帮忙?
<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>