我想使用 Geoxml3 在 googlemap 上加载 kmlfile,googlemap 已加载但未显示图层,我不知道我的代码有什么问题,谁能帮忙?
<script type="text/javascript">
var mapInstance;
var parser;
function doAlert() {
alert("Parsed triggered!");
}
function initialize() {
console.log("in init");
var latlng = new google.maps.LatLng(41.1188827, 1.24449090);
var mapOptions = {
zoom: 14,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DEFAULT
}
};
mapInstance = new google.maps.Map(document.getElementById("map"), mapOptions);
parser = new geoXML3.parser({
map: mapInstance,
zoom: false,
processStyles: true,
singleInfoWindow: true
}
);
google.maps.event.addListener(parser, 'parsed', doAlert);
parser.parse('postes.kml');
}
</script>
</head>
<body onload="initialize()">
<div id="map" style="width: 100%; height: 100%"></div>
</body>
</html>