0

Trying to recreate an application made in carto v3 in the new version of carto (v4); here is the one which was create using v3. Problem we are running into is that we can't seem to figure out how to create multiple layers in v4, there is no documentation on a similar method like .createLayer() from v3.

Does anyone have some workable related v4 code I could look at?


function retrieveLayer(map, cartoLayerSource, layerSide) {
    return new Promise(function(resolve, reject) {
      cartodb.createLayer(map, cartoLayerSource)
          .addTo(map)
          .on('done',
              function(layer) {
                // console.log(layer);
                layerSides[layerSide] = layer;
                resolve("loaded")
              })
          .on('error', function(error) {
            // console.log(error);
          });
    })
  }

1 Answer 1

0

Here you have an example, using several layers, with carto.js v4: https://carto.com/developers/carto-js/examples/#example-add-more-layers.

Instead of createLayer you build your layers using new carto.layer.Layer

1
  • Thanks for that. Could you take a look at another question I have found here ? @Víctor Velarde Commented Oct 16, 2019 at 13:47

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.