Your search returned no results

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

    http://gis.stackexchange.com/
    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

    Layer Source Object

    Standard Layer Source Object (type: ‘cartodb’)

    Used for most maps with tables that are set to public or public with link.

    Arguments

    Layer Source Objects are defined with the Layergroup Configurations.

    Name Description
    type A string value that defines the layer type. Required.
    options Options vary, depending on the type of layer source you are using:
    mapnik See Mapnik Layer Options.
    cartodb An alias for Mapnik (for backward compatibility).
    torque See Torque Layer Options.
    http See HTTP Layer Options.
    plain See Plain Layer Options.
    named See Named Map Layer Options.

    Example

    {
      user_name: 'your_user_name', // Required
      type: 'cartodb', // Required
      sublayers: [{
        sql: "SELECT * FROM table_name", // Required
        cartocss: '#table_name {marker-fill: #F0F0F0;}', // Required
        interactivity: "column1, column2, ...", // Optional
      },
      {
        sql: "SELECT * FROM table_name", // Required
        cartocss: '#table_name {marker-fill: #F0F0F0;}', // Required
        interactivity: "column1, column2, ...", // Optional
       },
       ...
      ]
    }

    For other layer source definitions, see this example.

    Named Maps Layer Source Object (type: ‘namedmap’)

    Used for making public maps with private data. See Named Maps for more information.

    Example

    {
      user_name: 'your_user_name', // Required
      type: 'namedmap', // Required
      named_map: {
        name: 'name_of_map', // Required
        // Optional
        layers: [{
          layer_name: "sublayer0", // Optional
          interactivity: "column1, column2, ..." // Optional
        },
        {
          layer_name: "sublayer1",
          interactivity: "column1, column2, ..."
        },
          ...
        ],
        // Optional
        params: {
          color: "hex_value",
          num: 2
        }
      }
    }

    Multiple types of layers Source Object

    cartodb.createLayer combining multiple types of layers and setting a filter

    Example

    cartodb.createLayer(map, {
      user_name: 'examples',
      type: 'cartodb',
      sublayers: [
        {
          type: "http",
          urlTemplate: "http://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}.png",
          subdomains: [ "a", "b", "c" ]
        },
        {
         sql: 'select * from country_boundaries',
         cartocss: '#layer { polygon-fill: #F00; polygon-opacity: 0.3; line-color: #F00; }'
        },
      ],
    }, { filter: ['http', 'mapnik'] })