I am using CartDB Javascript.

How can we use the sub-layer methods, GetSQL () and SetSQL (), on Named Maps?

I believe that with Named Maps, we need to provide the API key. But I can't seem a way to do this with only CartoDB.JS.

I found setAuthToken () method but I'm not sure how to use that either.

1 Answer 1


If you want to change the SQL and/or cartocss it's better to make the tables you are going to use public than using you api key. Names maps are created when the tables used in a map are private so the SQL for the map can't be changed.

When the tables are public named maps are not used instead sql and cartocss is free so you can build your application.

If your tables contain information you don't want to share then you have two options:

  • create you own named map but some templated variables
  • create tables with the data you want to share and make them public

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.