How do you set the extent of a sublayer to fit all of the points?

I've been trying to use this bounds function, but it doesn't work:

sql.getBounds('select * from table').done(function(bounds) {
  • What doesn't work? Is there any message in the command console? What does the rest of your code look like? Are you using createLayer or createVis? Commented May 20, 2015 at 12:49

1 Answer 1


As Andrew says, your approach should be working.

For example:

   var sql = new cartodb.SQL({ user: 'iriberri' });
   sql.getBounds("SELECT * FROM world_borders_9").done(function(bounds) {

You can see this code live working here.

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.