Here is my code:

    cartodb.createVis(map, 'https://blahblah/viz.json')
      .done(function(vis, layers) {
        console.log("Layers has " + layers.length + " layers.");

when it gets to the last line, I get the error above. Is the syntax wrong or something? I am inexperienced with js and html. The previous line resolves fine, I get the message "Layers has 3 layers" in the console.

I am including cartodb.js 3.15.8.


The correct syntax is with brackets, not parens. In other words the correct syntax is:



| improve this answer | |
  • 1
    That's it. If you check your viz.json, you can learn more about the layers structure. In a viz, regularly layers[0] is the basemap, and layers[1] are the data layers. Other layer types such as Torque layers would come as another independent layer such as layers[2]. – iriberri Nov 18 '15 at 10:50

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.