1

I'm almost totally new to CartoDB. I've been looking around and read the api reference, but there seems not to be what I'm looking for.

What I want to do is to "Create visualizations at runtime". From what I read, it is possible to do it only if you already have a visualization created with the UI and then you can work with sublayers.

But what I actually want to do is to create a visualization from scratch, using just the table containing the values I want to represent on the map.

Is this possible or I'm totally out of mind?

2

Yes, totally possible. That is what this portion is about Visualization at runtime

You'll see that the method doesn't include anything about an existing visualization, but just defines sublayers for a new one on the fly. The sublayers contain info about the table and columns you wish to use. Here it is generically,

cartodb.createLayer(map, {
  user_name: 'your user name',
  type: 'cartodb',
  sublayers: [{
    sql: "SELECT * FROM table_name",
    cartocss: '#table_name {marker-fill: #F0F0F0;}'
  }]
})
.addTo(map)

Where table_name is just that, the table you want to turn into a visualization. Your username can be found by the URL of your account, it is always http://username.cartodb.com... when you are signed in.

|improve this answer|||||
  • Thanks for your quick reply. Actually that's what i'm trying to do, but i always receive a 404.. no idea on how to debug it... Any clue? – sissy Mar 3 '14 at 17:06
  • Hmm... Perhaps your table is private? If you are on a free account, this shouldn't be the case. Are you using chrome? Could you drop a link to one of your failed tile requests? – andrewxhill Mar 3 '14 at 17:07
  • I'm using a free account, and yes using chrome. is that a problem? trying with ff, in console i get no errors... this should be the link you asked sissy0584.cartodb.com/tables/output_new – sissy Mar 3 '14 at 17:10
  • i tried with a different table and that seems to work... really strange behaviour. Thanks for your help indeed :) i had a moment of total panic :) – sissy Mar 3 '14 at 17:19
  • anyway you can create a public gist (gist.github.com) of your code? – andrewxhill Mar 4 '14 at 20:52

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.