complete guide to google ajax search api

Post on 13-Jan-2015

1.287 Views

Category:

Technology

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

 

TRANSCRIPT

Complete Guide to Google Ajax Search API

Explained by Rohit Ghatolrohitsghatol@gmail.com

Why use Google Ajax Search API?

• Allow user to search on your site• Allow user to get categorized search results• Allow the search results to be restricted to a domian• Help user with recommended search key words• Show Video Bar, Book Bar, Blog bar and News Bar

Getting Started

1. Get a Google Ajax Search API Key for your domain2. Code for Categoried search results3. Code for chaning look and feel and position of search

results4. Code for restricting Search results to a Domain5. Code for adding Map Search, Video Search6. How to use wizards for Book/Blog/Video/News Bar7. How to setup a Custom Search Engine8. Using the Custom Search Engine to refine search results

Get the Key from this Page

GSearchControl

GwebSearch

div with id “searchcontrol”

Code for Categorized Search Result

Code for Categorized Search Result

<html><head><script src="../../api?file=uds.js&amp;v=1.0" type="text/javascript"></script><script type="text/javascript">//<![CDATA[...................... (see next slide)//]]></script></head><body><div id="searchcontrol">Loading</div></body></html>

Code for Categorized Search Result<script type="text/javascript">//<![CDATA[function OnLoad() {// Create a search controlvar searchControl = new GSearchControl();// Add in a full set of searchersvar localSearch = new GlocalSearch();searchControl.addSearcher(localSearch);searchControl.addSearcher(new GwebSearch());searchControl.addSearcher(new GvideoSearch());searchControl.addSearcher(new GblogSearch());searchControl.addSearcher(new GnewsSearch());searchControl.addSearcher(new GimageSearch());searchControl.addSearcher(new GbookSearch());// Set the Local Search center pointlocalSearch.setCenterPoint("New York, NY");// tell the searcher to draw itself and tell it where to attachsearchControl.draw(document.getElementById("searchcontrol"));// execute an inital searchsearchControl.execute("VW GTI");}GSearch.setOnLoadCallback(OnLoad);//]]></script>

top related