appendChild kmz仅在我运行游览时第二次有效(游览进入同一kmz) [英] appendChild kmz works only in second time when I run a tour (tour is into the same kmz)

查看:115
本文介绍了appendChild kmz仅在我运行游览时第二次有效(游览进入同一kmz)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个用于GE插件的KMZ文件.此文件包含大量PNG,以及数个kml(多边形,线条,地标等).

I have a KMZ file for GE plugin. This file have lots of PNG into, and several kml (poligons, lines, placemarks, etc).

运行此游览的功能是:

function loadKmztour(href){
google.earth.fetchKml(ge, kmlURL, function(kmlObject) {
     if (kmlObject){
        ge.getFeatures().appendChild(kmlObject);
        walkKmlDom(kmlObject, function(context) {
            if (this.getType() == 'KmlTour') {
                ge.getTourPlayer().setTour(this);
                ge.getTourPlayer().play();
            }
        });
    });

}

运行良好,但是只有第二次运行巡回演出.第一次运行该浏览器时,它仅运行游览,但不显示poligon,地标和png,但是如果我第二次单击该游览,则可以正常运行.

It runs well, but only the second time when I run the tour. When I run it for first time, it run only the tours but doesn't show the poligons, placemarks and png, but if I click the tour for second time, it work fine.

如何强制在第一次加载kmz信息?

How can I force the kmz info to load at first time?

感谢您的帮助. 最好的祝福, 顺寿.

Thank you for any help. Best Regards, Shunsho.

更新:有时,第一次加载kmz poligon和地标...但仅在某些情况下有效...我认为游览可能会在添加kmz之前开始,所以问题是我如何可以强制等待appendChild然后运行导览...谢谢!

UPDATE: Sometimes, the kmz poligons and placemarks load at the first time...but it work only sometimes...I think that maybe the tour started to run before the kmz is appended, so the problem is how I can force to wait the appendChild and then run the tour...Thanks!

推荐答案

尝试播放直到加载kml之前,再进行游览.我使用以下代码:

try to wait until the kml is loaded before playing the tour. I use this code:

var interval = setInterval(function wait() { var streamingPercent = ge.getStreamingPercent(); if(streamingPercent > 98) { ge.getTourPlayer().setTour(tour); ge.getTourPlayer().play(); clearInterval(interval); } }

var interval = setInterval(function wait() { var streamingPercent = ge.getStreamingPercent(); if(streamingPercent > 98) { ge.getTourPlayer().setTour(tour); ge.getTourPlayer().play(); clearInterval(interval); } }

这篇关于appendChild kmz仅在我运行游览时第二次有效(游览进入同一kmz)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆