Introduction to Google Ajax APIs

Source: Internet
Author: User

 

 

Google Ajax API unifies Google's own JS library and current mainstream JS library, including YUI and Ext. JS, Dojo, jQuery, SWFObject, and different versions, as well as compression and non-compression, provide developers with dynamic and automatic loading features, opening up a new situation.

Load

On the Google website, it is prompted that the API key is required for use, but it is not actually required. Google has already opened all of them. The following simple code can be used to reference Google Ajax APIs:

1. <script type = "text/javascript" src = "https://www.google.com/jsapi"> </script>

GoogleLoader

On the whole, the key to Google Ajax API is Loader. Each JS library exists as a module and is dynamically loaded. The rule is as follows:

1. google. load (moduleName, moduleVersion, optionalSettings)

Where: moduleName: Module name;

ModuleVersion: module version;

OptionalSettings: Optional. The attributes include: callback:

Callback after loading is completed;

Language: The UI language of the loaded module;

Nocss: bool type. whether to add CSS related to the module. The default value is false;

Packages: specify other related packages involved in the use of the module;

Base_domain: Specifies the top-level domain of a module. For example, if the GoogleMap module maps is loaded and the specified domain is ditu.google.cn, the map API of the Chinese version is automatically loaded;

Other_params: Other parameters are completed using the <script> tag. For details, refer to the Google website.

Currently, JS libraries that do not support dynamic loading include: Friend Connect Earth gData Orkut. They do not support callback.

Sample loading Module

1. <script type = "text/javascript">

2. google. load ("search", "1 ");

3. google. load ("jquery", "1.4.2 ");

4. google. load ("jqueryui", "1.7.2 ");

5. </script>

Callback

1. function mapsLoaded (){

2. var map = new google. maps. Map2 (document. getElementById ("map "));

3. map. setCenter (new google. maps. LatLng (37.4419,-122.1419), 13 );

4 .}

5.

6. function loadMaps (){

7. google. load ("maps", "2", {"callback": mapsLoaded });

8 .}

This article is from the blog "Excellent by focus-Peng Jinhua"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.