我的 HTML 如下
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps JavaScript API v3 Example: Directions Complex</title>
<style>
html{height:100%;}
body{height:100%;margin:0px;font-family: Helvetica,Arial;}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript" src="http://geoxml3.googlecode.com/svn/branches/polys/geoxml3.js"></script>
<script type="text/javascript" src="http://geoxml3.googlecode.com/svn/trunk/ProjectedOverlay.js"></script>
<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('google_earth_tutorial_files.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>
但问题是在我的机器上我在开发者工具上遇到错误
GET google_earth_tutorial_files.kml geoxml3.js:1169
geoXML3.fetchXML geoxml3.js:1169
fetchDoc geoxml3.js:160
parse geoxml3.js:155
(anonymous function) testmypage2.html:35
n jquery.min.js:2
o.fireWith jquery.min.js:2
e.extend.ready jquery.min.js:2
c.addEventListener.B
我的 html 中的第 35 行是 geoXml.parse('google_earth_tutorial_files.kml');
我不知道为什么会这样。请帮忙。我可以看到地图,但没有加载任何 KML 图层
我的 KML 是
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<Placemark>
<name>Manfred Mustermann</name>
<description>Manfred Mustermann</description>
<Point>
<coordinates>7.0964850607874,51.781641735074,0</coordinates>
</Point>
<address>Musterstr 29 Aachen, 52070 Nordrhein-Westfalen</address>
<styleUrl>#0</styleUrl>
</Placemark>
</kml>