2

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) {
    map.fitBounds(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? – andrewxhill May 20 '15 at 12:49
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) {
   map.fitBounds(bounds)

You can see this code live working here.

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.