Search code examples
javascriptnode.jsreactjscartodb

How to integrate CARTO map to react.js code


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?


Solution

  • 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