Last active
August 29, 2015 14:10
-
-
Save iriberri/759cc58cd67c62d1acc3 to your computer and use it in GitHub Desktop.
Getting time and steps from Torque
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function main() { | |
var torqueLayer; | |
var url = 'http://sdsfdsfb-0e853d047bba/viz.json'; | |
cartodb.createVis('map', url, { | |
search: false, | |
tiles_loader: true, | |
layer_selector: false, | |
https: true, | |
}) | |
.done(function(vis, layers) { | |
torqueLayer = layers[2]; | |
console.log(torqueLayer.getTime()); | |
console.log(torqueLayer.getStep()); | |
torqueLayer.on('change:time', function(changes) { | |
if (changes.step <= 185){ | |
document.querySelector('#four-percent').style.width='44%'; | |
}else{ | |
document.querySelector('#four-percent').style.width='57%'; | |
} | |
}) | |
}) | |
.error(function(err) { | |
console.log(err); | |
}); | |
} | |
window.onload = main; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment