1

Is it possible to select a Torque layer that is part of a visualization?

I am using CreateVis and creating button and layer selector so that the user can choose what appears on the map. However, the Torque layer do not act like the others sublayer and I cannot select it.

Is there a way to set SQL so that only part of the data are presented when a button is clicked for a Torque Layer, while having other "normal" layers on the map?

3

You can apply the torqueLayer.hide() and torqueLayer.show() methods to control the display of your Torque layer. There is also the torqueLayer.setSQL('...') option. With all of these, you need to make sure that your data is not set to private because these do not work with named maps unless you add some additional parameters to the config file.

A key thing to remember about Torque layers: they are their own layer as opposed to the static layers which consist of sublayers bundled into a single layer. The structure of layers which is returned as a callback object from createVis: layers[0] is the basemap layer, layers[1] are the static layers, and layers[2] is the Torque layer.

I made a working example here with some of the new heat maps! While this example does not use torqueLayer.setSQL('...') you can easily add it and customize it to your liking.

  • Great, thanks a lot for the clarification. I didn't realize Torque was its own layer, very helpful. It works now. However, the setSQL doesnt work when my Torque Layer is set under TORQUE CAT in the wizard. Only when I switch it to normal Torque I am able to select the data I want. Workaround? Torque CAT was useful to me bc I wanted different styling. – veroterio Feb 15 '15 at 17:46
  • in that case you need to apply full SQL. Torque cat uses a wrapped query, check what cartodb generates in that case – javisantana Feb 16 '15 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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