2

I have created Leaflet map using Carto and React, as it is described here https://github.com/IagoLast/cartojs-react-example, using:

const cartoSource = new carto.source.SQL(source);
const cartoStyle = new carto.style.CartoCSS(style);

this.layer = new carto.layer.Layer(cartoSource, cartoStyle);
client.getLeafletLayer().addTo(this.context.map);

Now i need to change this layer source dynamically somehow. Is it possible to change the layer source and how to do it? How to find specified layer from leaflet map? Or i need to delete this layer and create the new one?.

Juri K
  • 75
  • 3
  • *Why* do you need to change the layer source *dynamically*? Can't you just create the map with the layer source you want? – Jared Smith Jun 15 '18 at 14:56

1 Answers1

0

You would need to apply setQuery method on your cartoSource object. If necessary, you would need to change the style.

ramiroaznar
  • 266
  • 5
  • 15