0

A while ago I made a CartoDB/Torque animation that displayed hours and minutes while playing. Sujay v. helped me out with the code here:

https://groups.google.com/forum/#!topic/cartodb/xpxF4fSV7ZI

Essentially I changed some lines in the torque.js file as below:

torque.clock.set('<span id="month">' + date_arry[0] + ' ' + date_arry[1] + ', </span> <span id="year">' + date_arry[2] + ' ' + date_arry[3] + '</span>');

However I've come back to needing to do something similar, and the torque.js file has changed alot and I can't figure out how to implement something similar now. Would someone be able to advise? The source code is here:

https://github.com/CartoDB/torque/blob/master/dist/torque.uncompressed.js

Apologies I can't do this myself. I'm pretty good at SQL and GIS, but lacking the .js skills. :-(

Thanks

James

1 Answer 1

1

It's pretty easy, torque provides bindings to get the animation time:

        // each time time changes, change:time is raised
        // changes.time contains the Date objects
        torqueLayer.on('change:time', function(changes) {
          var month_year = changes.time.toString().substr(4).split(' ');
          $('.mytimedisplay').text(month_year[0] + " - " + month_year[2]);
        });

The code is from here: https://github.com/CartoDB/torque/blob/master/index.html#L266

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.