Your search returned no results

Try another search term or view Stack Exchange, where we have active conversations with Developers about GIS.
    Support channel in Stack Exchange

    Thousands of developers around the world have helped make CartoDB a success, and we have active conversations with them about GIS in Stack Exchange.

    Go to Stack Exchange

    Core API Functionality

    In case you are not using Leaflet, or you want to implement your own layer object, CARTO provides a way to get the tiles url for a layer definition.

    If you want to use this functionality, you only need to load cartodb.core.js from our cdn. No CSS is needed:

    <script src=""></script>

    An example using this functionality can be found in a ModestMaps example: view live / source code.

    Notice that cartodb.SQL is also included in that JavaScript file


    cartodb.Tiles.getTiles(layerOptions, callback)

    Fetch the tile template for the layer definition.


    Name Description
    layerOptions the data that defines the layer. It should contain at least user_name and sublayers list.
    callback(tilesUrl, error) a function that recieves the tiles templates. In case of an error, the first param is null and the second one will be an object with an errors attribute that contains the list of errors.


    In this example, a layer with one sublayer is created. The sublayer renders all the content from a table.

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

    The tilesUrl object contains url template for tiles and interactivity grids:

      tiles: [
      grids: [
        // for each sublayer there is one entry on this array