简体   繁体   English

创建Google GeoChart异步

[英]Creating Google GeoChart async

I want to put a GeoChart in my app but I don't want to create it when the DOM is loading. 我想在我的应用程序中放置一个GeoChart,但是我不想在加载DOM时创建它。 I only want to render after a user interaction. 我只想在用户交互后进行渲染。 I have loaded the google.visualization library including the GeoChart and CoreChart packages. 我已经加载了包括GeoChart和CoreChart软件包的google.visualization库。

When I am loading the Chrome console google.visualization.arrayToDataTable and google.visualization.GeoChart are missing! 加载Chrome控制台时,google.visualization.arrayToDataTable和google.visualization.GeoChart丢失了! The same code works when executing everything on DOM load. 在DOM加载上执行所有操作时,相同的代码也可以工作。

Any hints on how to properly the load the lib? 关于如何正确加载lib的任何提示?

Make sure you've included these two lines: 确保您包括以下两行:

google.load('visualization', '1', {'packages': ['geochart']});
google.setOnLoadCallback(drawRegionsMap);

But instead of making the callback drawRegionsMap, call some other function that handles when you load your chart. 但是,不要制作回调drawRegionsMap,而是调用其他一些在加载图表时处理的函数。 Hope that helps. 希望能有所帮助。

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

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