Javascript 谷歌地球插件:先加载static.kmz,然后播放tour.kmz?
有没有办法让Google Earth插件在加载网页时执行以下操作 显示静态.kmz文件,如中所示 启动一个tour player.kmz,如中所示Javascript 谷歌地球插件:先加载static.kmz,然后播放tour.kmz?,javascript,kml,google-earth,google-earth-plugin,kmz,Javascript,Kml,Google Earth,Google Earth Plugin,Kmz,有没有办法让Google Earth插件在加载网页时执行以下操作 显示静态.kmz文件,如中所示 启动一个tour player.kmz,如中所示 我可以分别执行上面的1或2项操作,但我不知道如何在加载网页时同时执行这两项操作。您可以使用中的方法加载这两个文件。然后,您可以提供处理显示数据和在回调参数中输入巡更的逻辑 要玩巡演,您必须在Kml DOM中查找对象,以便使用打开它。要做到这一点,您可以使用,也可以使用脚本 下面的java脚本应该可以工作,尽管它是在这里编写的,并且未经测试 <s
我可以分别执行上面的1或2项操作,但我不知道如何在加载网页时同时执行这两项操作。您可以使用中的方法加载这两个文件。然后,您可以提供处理显示数据和在回调参数中输入巡更的逻辑 要玩巡演,您必须在Kml DOM中查找对象,以便使用打开它。要做到这一点,您可以使用,也可以使用脚本 下面的java脚本应该可以工作,尽管它是在这里编写的,并且未经测试
<script src="//www.google.com/jsapi/"></script>
<script src="//earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js"></script>
<script>
google.load("earth", "1");
var ge = null;
var kml1= '//www.ppacg.org/tours/logo.html';
var kml2= '//www.ppacg.org/tours/tabview.html?project=08-37';
var tour = null; // so you can call pause, stop, etc globally...
function init() {
// presumes you have a div with the id 'map3d'
google.earth.createInstance("map3d", initCallback, function(e){alert(e);});
}
function initCallback(object) {
ge = object;
ge.getWindow().setVisibility(true);
// load your data
google.earth.fetchKml(ge, kml1, fetchKmlCallback);
google.earth.fetchKml(ge, kml2 , fetchKmlCallback);
}
function fetchKmlCallback(object) {
if (object) {
// add the features to the plugin
ge.getFeatures().appendChild(object);
// Walk the DOM looking for a KmlTour
walkKmlDom(object, function() {
if (this.getType() == 'KmlTour') {
tour = this;
ge.getTourPlayer().setTour(tour); // enter the tour
return false; // stop the DOM walk here.
}
});
} else {
setTimeout(function() {
alert('Bad or null KML.');
}, 0);
}
}
google.setOnLoadCallback(init);
</script>
还可以看看这些使用的例子,如果您遇到了问题。非常感谢Fraser,这非常有效!以下是更新后的网页: