I have successfully created a named map. I can initialize the map (as seen here), and I do get the correct response. Now, to my problem.

How do I show this layer (using the layergroupid I got as a response) on a map with CartoDB.js?

When I look at the documentation I see:

You can then use the layergroupid for fetching tiles and grids as you would normally (see anonymous map section)

In the anonymous section, I see the following

The tiles can be accessed using: http://{account}.cartodb.com/api/v1/map/:layergroupid/{z}/{x}/{y}.png

How is this done on the client side? Are there any examples out there where you start with a blank map, initialize a named map and add that layergroupid to the map? I have not managed to find such a thing.

2 Answers 2


The way to show that map client side once you have that layergroupid is using leaflet or any other mapping library using a tiled layer. For example in leaflet


cartodb.js simplifies the process to get that layergroup and gives you useful methods to change it, for example, generate a new map changing the SQL or CartoCSS.

If you are going to use cartodb.js it's better to use that to get that layergroup.


I came across this posting because I too was trying to user the layergroupid directly. It wasn't clear from the docs that this is primarily for internal use in cartodb.js. I also misunderstood from the API docs how the Named maps were intended to work with cartodb.js.

In case someone else is missing the obvious, this document was key for me: http://docs.cartodb.com/tutorials/named_maps.html

Javi, it would be really helpful to link to that doc from the Maps API so its easier to understand how you intend that feature to be used if you come at it from the API side.

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.