gapi.client.load与google.load [英] gapi.client.load versus google.load

查看:250
本文介绍了gapi.client.load与google.load的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何正确加载Google的API感到困惑。我看到提及了两种不同的方法:

第一:Google API加载器( https://developers.google.com/loader )。我在html文档中看到了这样的用法:

 < script src =https://www.google.com / JSAPI>< /脚本> 

然后在JS文件中使用它:

  google.load('visualization','1.0',{'packages':['corechart']})



第二:Google API Javascript客户端( http://code.google.com/p/google-api-javascript-client/ )。这个被加载如下:

 < script src =https://apis.google.com/js/client。 JS>< /脚本> 

然后用于:

 gapi.client.load('fusiontables','v1')



<如果你查看这两个API中的每一个的文档,我会得到第二种方法是当前现代方法的印象,而第一种方法比较老。较旧的方法支持较少的API,但它们不相同。我想在我的应用程序中使用Fusion Tables和Google Charts。据我所知,我认为我需要加载这两个API。



我的问题:这两个API确实是独立的彼此?我是否正确地将google.load方法解释为较旧的传统内容?如果我需要使用这两种API,它们之间是否存在任何冲突?

感谢您的任何想法!

解决方案

您的评估是正确的。这些API彼此不同,并且在加载它们时不应该有冲突(尽管在做任何工作之前,你应该验证它们的加载方法已经被解雇了)。但我不会将google.load API描述为遗留; google.load是加载某些Google JS客户端的一般机制,并不反映底层客户端库的状态。


I am confused about how to properly load Google's APIs. I see mentioned two different approaches:

First: Google API loader (https://developers.google.com/loader). I see this used like so within the html document:

<script src="https://www.google.com/jsapi"></script>

Then later in a JS file it gets used like this:

google.load('visualization', '1.0', {'packages':['corechart']})

Second: Google API Javascript Client (http://code.google.com/p/google-api-javascript-client/). This one gets loaded like:

<script src="https://apis.google.com/js/client.js"></script>

and then used later like:

gapi.client.load('fusiontables', 'v1')

If you look up the documentation for each of these two APIs I get the impression that the second approach is the current 'modern' approach, while the first is older. The older method supports fewer APIs that the newer one, but they are not the same. I am wanting to use both Fusion Tables and Google Charts in my application. As far as I can tell I think I need to load up both APIs.

My Questions: Are these two APIs indeed distinct and independent from each other? Am I correct in interpreting the "google.load" methods as being older "legacy" stuff? If I need to use both APIs, are there any conflicts between them?

Thanks for any ideas!

解决方案

Your assessment is correct. These APIs are distinct from each other, and there should not be a conflict in loading both of them (Although you should verify that both of their "on load" methods have been fired before doing any work). However I wouldn't characterize the google.load APIs as "legacy"; google.load is a general mechanism for loading certain Google JS clients, and is not a reflection of the status of the underlying client library.

这篇关于gapi.client.load与google.load的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆