gSearch | About

Google Search Plugin for jQuery

Getting started…

…with gSearch is very easy. Simply follow these steps and you're ready to go!

  1. Requirements
  2. Installation
  3. HTML structure
  4. Creating a map
  5. Customizing

Requirements

There are a two requirements you need to meet before you can use gSearch to display Google Maps on your website. First you need to sign up for a Google Search API key. Second you need the jQuery library which can be retrieved using the Google API (recommended) or downloading from the jQuery site and hosting on your own. jQuery must at least be version 1.3.

Installation

Download the latest version of gSearch and include the AJAX Libraries API along with jQuery and Google Search in the <head> section of your website. Don't forget to replace "API_KEY" with your actual API key or the map won't work when used on a real domain!

<script type="text/javascript" src="http://google.com/jsapi?key=YOUR_API_KEY"></script>
<script type="text/javascript">google.load("jquery", "1");</script>
<script type="text/javascript">google.load("search", "1");</script>
<script type="text/javascript" src="js/jquery.gSearch-1.0-min.js"></script>

HTML structure

The HTML structure is quite simple too. Just place a <div> somewhere on your page, style it with CSS (don't forget to assign a fixed width & height) and give it a unique ID or class.

<div id="search-results"></div>

Creating a search

Select the new div element using jQuery's selectors and call the gSearch() function on it. I recommend to call the function as soon as the DOM is ready. Please refer to jQuery Events/ready for further infomation.

$("#search-results").gSearch({search_text : 'brian griffin'});

Customizing

gSearch can be customized in many different ways. All you need to do is to pass a JSON object to the gSearch() function. Please see below for a complete list of properties that can be passed. Items with no default value are mandatory.

search_text: string
Default: ""
Text which google will search the web with.
count: integer
Default: 4
Number of results shown. Can be either 4 or 8.
site:string
Default: "".
The URL which Google will search includes any domains or folders searchable.
pagination:boolean
Default: true
Condition to build pagination.