3

I'm trying to integrate CARTO map (created using CARTO builder) with react.js.

I'm stuck at using carto.js via cartoclient:

this.cartoClient = new carto.Client({ apiKey: 'key', username: 'user' });

Official CARTO documentation mentions that it's possible to integrate the map using viz.json file, but there are no reference to any working example of that.

This example is creating map from scratch and this one is using plain html with scripts (no react.js support)

Are there any suggestions?

WeMakeSoftware
  • 9,039
  • 5
  • 34
  • 52
Juri K
  • 75
  • 3

1 Answers1

1

The confusion here is that documentation at https://carto.com/docs/carto-engine/carto-js/ refers to version 3 while the React example you saw is using version 4 which documentation is now living here https://carto.com/developers/carto-js/

We are in the process of deprecating /docs, sorry for the inconvenience.

Regarding your question the answer is that nowadays we don't have a way to instantiate Builder maps wich CARTO.js. That may change in the future but at this moment we don't support viz.json.

Disclaimer: I work at CARTO

Jorge Sanz
  • 341
  • 2
  • 4
  • So the only way is to make the same map in react and carto.js(with carto.Client) is manually using carto builder datasets (if it is possible?) – Juri K Apr 25 '18 at 08:55
  • Yes, you have to add your layers as combinations of queries (or table names) and CartoCSS definitions. – Jorge Sanz Apr 25 '18 at 12:20