I am trying to use the cartodb.core.js library to render my own tiles. According to what I see, the Tiles library is only available in the cartodb.core.js. And if we use that we don't get the createLayer function, which is fine if I can just get the Tiles to load, and I can render them myself:

var layerData = {
  user_name: 'swc28',
  sublayers: [{
    sql: "SELECT * FROM zoning",
    cartocss: '#layer { marker-fill: #F0F0F0; }'
cartodb.Tiles.getTiles(layerData, function(tiles, err) {
  if(tiles == null) {
    console.log("error: ", err.errors.join('\n'));
  console.log("url template is ", tiles.tiles[0]);

But I've never rendered layers like this myself, and I looked at the library without much success to figure out how to do it. So my question is: How does the CartoDB UI library render the tiles from a template url that is returned form the call above?

The template url looks like this:


It depends on the mapping library you are using, each one has its own way to add tiled layers.

For example for leaflet the way to do this would be:


I've created a full example.


  • Thanks! I wonder if it's possible to also simulate the featureOver events of the vis library with this approach.
    – picardo
    Oct 25 '14 at 15:41
  • Yes, you'd need to use leaflet utfgrid plugin and the urls cartodb provides for interaction Oct 25 '14 at 23:25

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.