简体   繁体   English

javascript-如何在Google Earth中设置kml文件的动画范围

[英]javascript-how to set the animation range of kml file in google earth

Currently, if I click the button, the map will start to animate. 当前,如果我单击按钮,则地图将开始设置动画。 But it never stops, it animates infinitely. 但是它永远不会停止,它会无限地动画。 If there is a map/file is from 2004-2008, I just want that it stops on 2008-12-31 automatically. 如果地图/文件来自2004-2008,我只希望它在2008-12-31自动停止。 How can I do that? 我怎样才能做到这一点?

I tried 我试过了

var timeSpan = ge.createTimeSpan('');
timeSpan.getBegin().set('2004');
timeSpan.getEnd().set('2008');
ge.getTime().setTimePrimitive(timeSpan);

But it does not work, I think it may not work for my purpose. 但这是行不通的,我认为可能无法达到我的目的。 So please help me, I am so strugling.... 所以请帮助我,我很挣扎...

There's a few things you can do, and it's hard to know what to recommend without know more what you are trying to build. 您可以做几件事,而又不了解要构建的内容,很难知道该推荐什么。 One suggestion: 一个建议:

  • Don't use the default time slider UI, but rather hide it away and create your own button 不要使用默认的时间滑块UI,而是将其隐藏起来并创建自己的按钮
  • On clicking the button, set the time for the plugin to 2004. 在单击按钮时,将插件的时间设置为2004。
  • Decide upon whatever virtual clock rate you want (eg one virtual month per real second, or whatever) 确定您想要的虚拟时钟速率(例如,每秒钟每秒一个虚拟月,或其他)
  • Calculate how long it would take, in real seconds, to get to 2008 计算以秒为单位的到2008年的时间
  • do a setTimeout that sets the clock rate to 0 after the appropriate amount of real time has passed (eg when the virtual plugin clock makes it to 2008) 执行setTimeout,以在经过适当的实时量后将时钟速率设置为0(例如,当虚拟插件时钟设置为2008年时)

This way a user can'd be fiddling with the UI (eg dragging the slider around) in a way that interferes with the story you are probably trying to tell... 这样,用户就可以摆弄用户界面(例如,拖动滑块),从而干扰您可能想讲述的故事...

You can see examples of much of the code mentioned above at http://code.google.com/apis/ajax/playground/#internal_clock_rate and some additional documentation at http://code.google.com/apis/earth/documentation/time.html 你可以看到在很多上面提到的例子代码http://code.google.com/apis/ajax/playground/#internal_clock_rate在和一些额外的文件http://code.google.com/apis/earth/documentation /time.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM