我为谷歌地球之旅生成了一个kml,
每次我需要点击“开始游览”来运行游览。
我希望在加载kml文件后,巡视应该在没有用户干预的情况下运行,并且应该自动重复。
有人可以帮忙吗?任何人请
谢谢&问候, 皮卡
答案 0 :(得分:0)
这里我附上了一个简单的旅游应用程序。它自动启动,无需任何人为干预。如果您想了解更多关于google earth api tour的信息,请参阅此链接。 https://developers.google.com/earth/documentation/touring
<html>
<head>
<title>Sample tour in the Google Earth Plugin</title>
<script src="https://www.google.com/jsapi"> </script>
<script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"> </script>
<script type="text/javascript">
var ge;
var tour;
google.load("earth", "1");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
var href = 'http://developers.google.com/kml/documentation/kmlfiles/complete_tour_example.kml';
google.earth.fetchKml(ge, href, fetchCallback);
function fetchCallback(fetchedKml) {
// Alert if no KML was found at the specified URL.
if (!fetchedKml) {
setTimeout(function() {
alert('Bad or null KML');
}, 0);
return;
}
// Add the fetched KML into this Earth instance.
ge.getFeatures().appendChild(fetchedKml);
// Walk through the KML to find the tour object; assign to variable 'tour.'
walkKmlDom(fetchedKml, function() {
if (this.getType() == 'KmlTour') {
tour = this;
ge.getTourPlayer().setTour(tour);
ge.getTourPlayer().play();
return false;
}
});
}
}
function failureCB(errorCode) {
}
google.setOnLoadCallback(init);
</script>
</head>
<body>
<div id="map3d" style="height: 400px; width: 600px;"></div>
</body>
</html>