How to reset the timeline and animation widgets to default settings?

How would I reset the timeline and animation widgets to their default settings of showing the current time? My scenario:

When I first load a viewer which contains an animation and timeline widget it is showing the current date and time. Then I load some CZML data which updates the animation/timeline to the date and time in the CZML data.

After I'm done viewing the CZML data I clear the map of everything including the CZML data. This all works fine but after clearing the map, the animation and timeline widgets still show the date and time from the data I just cleared. I want to be able to reset these things back to what they were like when the viewer first loaded.

Any ideas? Thanks.

There’s not a single method to reset the clock to default, but you can set the clock parameters yourself after you clear the data sources:

var now = new Cesium.JulianDate();

viewer.clock.currentTime = now;

viewer.clock.startTime = now.clone();

viewer.clock.stopTime = now.addDays(1.0);

viewer.clock.multiplier = 1.0;

viewer.timeline.updateFromClock();

viewer.timeline.zoomTo(viewer.clock.startTime, viewer.clock.stopTime);

Scott,

This works perfectly. Thanks for your help!

Thank you Scott.It really helps me too. But I wonder if the documentation should be improved because If I haven’t seen this post, I have not imagined that this property currentTime can be accessed and modified. Such get and set propertry should be mentioned somewhere in the documentation. Or may be I am not still feel comfortable within the cesium documentation.
Regards

If you start on the Viewer page, you can find the clock property which links to the Clock documentation which does contain the property currentTime. Unfortunately, the doc for it is simply “The current time”, which isn’t very helpful. At the very least it should be “Gets or sets the current scene time”.

We’re always looking to improve our documentation. I actually have a longstanding issue to at least improve basic property documentation: https://github.com/AnalyticalGraphicsInc/cesium/issues/1661 If you’d like to help improve Cesium documentation, that would be a great place to start.

I’m always hoping we can get some more regular contributors on Cesium, and often times users are the best people to help improve documentation since they can draw from their own experience of trying to learn how to do something.

Thanks for this thread. I've been poking around in Cesium documentation and in various threads like this to understand how to update the timeline with new clock parameters (start/end times), but I must be missing something as I am not getting the result I expect. Any guidance on the exact steps to do this would be helpful. My scenario:

I am loading in a data source that is updated each day with new data. All works fine....everyday, the timeline grows from the first time stamp in the data source to the current time (realtime). For this, I have been using default clock/timeline settings associated with a new viewer. Now, our data stream has terminated so our data source is no longer changing. I don't want the end time on the timeline to keep growing as realtime progresses. I just want to fix an end time that is appropriate to the data. I have tried various permutations and can't seem to get the timeline updated. Any advice/assistance and sample code would be appreciated! Many thanks in advance.