简体   繁体   English

如何将CARTO映射集成到react.js代码中

[英]How to integrate CARTO map to react.js code

I'm trying to integrate CARTO map (created using CARTO builder) with react.js. 我正在尝试将CARTO地图(使用CARTO构建器创建)与react.js集成。

I'm stuck at using carto.js via cartoclient: 我坚持使用cartoclient使用carto.js:

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. 官方CARTO文档提到可以使用viz.json文件集成地图,但没有任何参考任何工作示例。

This example is creating map from scratch and this one is using plain html with scripts (no react.js support) 这个例子是从头开始创建map, 这个是使用带脚本的普通html(没有react.js支持)

Are there any suggestions? 有什么建议吗?

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/ 这里的困惑是https://carto.com/docs/carto-engine/carto-js/上的文档引用version 3而您看到的React示例使用的是version 4 ,文档现在位于此处https:// carto .COM /开发商/ CARTO-JS /

We are in the process of deprecating /docs , sorry for the inconvenience. 我们正在弃用/docs ,很抱歉给您带来不便。

Regarding your question the answer is that nowadays we don't have a way to instantiate Builder maps wich CARTO.js. 关于你的问题,答案是,现在我们没有办法用CARTO.js实例化Builder地图。 That may change in the future but at this moment we don't support viz.json. 这可能会在未来发生变化,但此时我们不支持viz.json。

Disclaimer : I work at CARTO 免责声明 :我在CARTO工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM