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!
GAPI is Google's client library for browser-side JavaScript. It's used in Google Sign-in, Google Drive, and thousands of internal and external web pages for easily connecting with Google APIs.
init( args ) Initializes the JavaScript client with API key, OAuth client ID, scope, and API discovery document(s). If OAuth client ID and scope are provided, this function will load the gapi. auth2 module to perform OAuth.
An AngularJS module for using all Google Apis and your Google Cloud Endpoints (Google App Engine) with OAuth. This module uses Google APIs Client Library for JavaScript, available for all GApis. NPM.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With