简体   繁体   中英

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. 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
  • On clicking the button, set the time for the plugin to 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
  • 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)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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