我的应用程序无法识别我的 KML 文件。应用程序将转到正确的位置(纬度/经度)和缩放级别,但无法识别 KML 文件位置。我试图使用两个不同的服务器来检查问题,所以我相信问题出在代码上。
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyDOJCBv2WGJRJ7uxOyAMehKAMiAKXkkHFU&sensor=true">
</script>
<script type="text/javascript">
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(44.88119,-93.314798),
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
var nyLayer = new google.maps.KmlLayer('http://webgis.uwm.edu/engelki7/KMLFiles/Richfield_Homes2.kml',{suppressInfoWindows: true});
google.maps.event.addListener(nyLayer, 'click', function(kmlEvent) {
var text = kmlEvent.featureData.description;
showInDiv(text);
});
}
function showInDiv(text) {
var sidediv = document.getElementById('content_window');
sidediv.innerHTML = text;
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:79%; height:100%; float:left"></div>
<div id="content_window" style="width:19%; height:100%; float:left"></div>
</body>
</html>