The Google AJAX Search API is a JavaScript API implemented in the following classes.
An instance of GSearchControlgoogle.search.SearchControl represents a single search control on a page. Each search control manages the presentation of the user interface object and the search mechanism for a selected set of searcher objects (objects which implement the GSearch google.search.Search interface).
| Constructor | Description |
|---|---|
| Creates a new search control object. The search control object is a container for searchers, objects which implement the The expected order of operations is:
Once these steps have occurred, the search control is active and ready to begin performing searches. |
| Method | Description |
|---|---|
| This method adds a searcher object to the search control. Once added, the search control will coordinate the activities of the searcher. It will coordinate the execution of searches, handle the related search completion events, provide a location where results are to be rendered, and provide a ui for "keeping" or "clipping" search results. The method accepts an optional
|
| This method is the final step needed to activate a search control object. It may only be called once all searchers have been added into the search control. When called, this method produces the user interface, search result containers for each configured searcher, and finally sets of the various linkages needed to coordinate parallel searches across all of the searchers. The method requires that the caller supply an html block element, typically a The default user interface style is a linear style where the control inputs are at the top followed by a linear set of stacked results. Optionally, callers may request a tabbed user interface which works well when vertical real estate is at a premium.
|
| When an application is providing its own input control and asking the search control to use that, the search control uses an input timer to determine when to execute a search. Each time a user types into the search controls text input area, a countdown timer is initialize. When the timer executes, a search is requested. The time lag between the last keystroke and the initiation of a search is programmed using this API. Note: The default value of the control is
|
| This method causes the search control to initiate a sequence of parallel searches across all of the searchers configured into the control. If the As a side effect of this call, the current set of search results displayed, as well as the search results stored within each of the controlled searcher objects is cleared.
|
| This method is used to inform the search control that the caller would like to be notified when a user has selected for copy, one of the search results managed by the control. If this method is not called, then the user is not offered an opportunity to copy search results. If the method is called, each search result is annotated with a text link, underneath the search result. Clicking on this link will cause the specified method to be called on the specified object, passing in a
|
| This method is called to select the number of results returned by each of the searchers. Note, this is not a scalar. It is an enumeration that indicates either a small number of results, or a large number of results. In the future, this method may be enhanced to support medium and extra large result sets. From the sample applications, you have probably seen the more/less twiddle control at the top of the search control. This method is used by that twiddle control.
|
| This method is used to tell the search control to ignore all incoming search result completions. The internal state used by this method is reset, to allow searches each time a new search is requested. The intended use of this method is to help applications cope with ui flashing that can occur as slow input triggers inadvertent searches. By using this method each time input is sensed, previous searches based on partial input can easily be ignored.
|
| This method is used to clear all of the search results out of the search control.
|
| This method is called to set the link target used for links embedded in search results. The default value is
|
| This method is used to inform the search control that the caller would like to be notified when a search completes. Note, the granularity of this call is the searcher level, NOT the search control level. What this means is that if your search control contains 5 searchers and you execute a search, as each searcher completes, your callback will be called. Note also, that not all searches will result in completion so be careful not to code deadlocks where you assume that a single completion will occur for each search.
|
| This method is used to inform the search control that the caller would like to be notified right before a search begins. Note, the granularity of this call is the searcher level, NOT the search control level. What this means is that if your search control contains 5 searchers and you execute a search, as each searcher is told to begin searching, your method will be called.
|
| Normally, when a search produces no results, the search control slot for the searcher is left empty. This method allows the caller to specify a string that supplies a default "result". The system contains a value of
|
| Static Method | Description |
|---|---|
| This utility function is used to clone the current computed style for the specified html node (or tree if opt_deep is specified) and inline the current style into the node. In some instances this function is useful, mainly in conjunction with an on keep handler where the application wishes to preserve a set of html styles while passing a piece of html from one application to another, where the receiving application does not have the associated style sheet. The simplest example of this scenario is in the case of an email application where the email application is using the Google AJAX Search API to allow users to clip search results into a message composition window where they will be emailed as html to another user. The recipient's email application in some cases will have no knowledge of Google AJAX Search API and will therefore not normally carry its style sheet. To account for this, we provide this method so the originating email application can inline the current styles so that the recipient can read the message with full fidelity.
Note: this method is not currently implemented on the Safari web browser. |
This object does not expose any public properties.
Applications that use the GSearchgoogle.search.Search objects in standalone form, rather than under control of the GSearchControlgoogle.search.SearchControl will often have a need to capture and process user-generated search requests. The GSearchFormgoogle.search.SearchForm() object is a light weight object that is designed for exactly this use case. It provides applications with a text input element, a search button, an optional clear button, as well as all standard branding.
| Constructor | Description |
|---|---|
| Creates a new search form object. The search form object supplies user interface elements, methods, properties, and callbacks designed to allow applications to control a collection of The expected order of operations is:
Once these steps have occurred, the search form is active and ready to begin receiving and processing user input. The method accepts a required
|
| Method | Description |
|---|---|
| This method registers an object/method combination that is called when the search form is "submitted". This event occurs when the user clicks on the search button, or when the user hits enter while focused on the text input element. When this occurs, the specified object becomes the active object and the specified method is called. The argument passed to the method is this search form. A typical method might look like this:
App.prototype.onSubmit = function(form) {
if (form.input.value) {
this.localSearcher.execute(form.input.value);
}
return false;
}
Note in the above example that the search form is passed to the method, and that the method returns false indicating that it has processed the submit event.
|
| This method registers an object/method combination that is called when the clear button in the search form is pressed. It is an error to call this method if the search form was created without a clear button. When this occurs, the specified object becomes the active object and the specified method is called. The argument passed to the method is this search form. A typical method might look like this:
App.prototype.onClear = function(form) {
this.myClearFunction();
return false;
}
Note in the above example that the search form is passed to the method, and that the method returns false indicating that it has processed the clear event.
|
| This method allows an application to "submit" the form. This involves optionally setting the form's text input element and then calling the registered on-submit callback method established using
|
This object does not expose any static methods.
The following collection of public properties are exposed by the google.search.SearchForm.
| Property | Description |
|---|---|
| This property is the text input element for the form. Applications are free to read and write this propertie at will. Typical use is that in an on-submit callback handler, an application will read |
| The search form's internal structure is a pair of HTML tables. The upper table contains the text input element, the localized search button, and an optional clear button. The lower table contains an application specific free cell, the left hand cell in the table, as well as a right aligned set of Google branding inlcuding both text and an image. This property, the |
An instance of the GSearchgoogle.search.Search class provides the ability to execute searches and receive results from a specific search service. This object is not directly used; it is a base class which service-specific searchers inherit from. The methods and properties described below apply to all objects that inherit from this base class. Each of those objects may supply additional interfaces as well.
The expected usage of this object is in conjunction with the GSearchControlgoogle.search.SearchControl where the search control provides both user interface and coordination. That said, it is perfectly acceptable for you to use this object independently, but just make sure you are not attempting to share the same instance of a searcher object between your application logic and a search control object.
| Constructor | Description |
|---|---|
| Creates a new searcher object. Note: Since this is a base class, it is unlikely that applications will make direct use of this constructor and instead will use the constructor as a side effect of creating a service specific searcher object (e.g., |
| Method | Description |
|---|---|
| This method is called to select the number of results returned by this specific searcher. Note, this is not a scalar. It is an enumeration that indicates either a small number of results, or a large number of results. In the future, this method may be enhanced to support medium and extra large result sets.
|
| This method returns the current result set size, the value established by the previous method.
|
| Upon successful completion of a search, the searcher object holds on to a collection of search results which describe the outcome of a particular search. This method is used to reset the searcher, clearing out all results. This method is implicitly called prior to the execution of a new search.
|
| This method is called to begin a new search. The
|
| This method is used to register and object and method to notify on the completion of a search. Applications may optionally pass in a context argument using
|
| This method is used to set a user defined label that should be used when this searcher is added to a search control. By calling this function, the user defined label specified will be used in the result section header or tab instead of the standard, built in labels. Expected usage is in conjunction with site restricted searching where it is both appropriate and expected that applications will indicate that they have programmed in restrictions by changing the standard label.
|
| This method is used to set a user defined class suffix for the search results section, and for the collection of search results produced by this searcher in the search control. The motivation for this method is to allow applications to set unique styling for the results and header of a particular set of search results. Assuming this method is called with a value of "siteSearch", a class of
|
| This method is called to set the link target used for links embedded in search results. The default value is
|
| There are times when your application is not using the search control and is only using a small set of properties from a search result and you are displaying these in a highly customized format. When this is the case, a small optimization is available to your application. The searcher can be programmed to NOT generate a .html property leaving you with only the raw properties valid in a result.
|
| For some classes of searchers (e.g., GlocalSearchgoogle.search.LocalSearch()), there is a requirement that attribution be displayed alongside the set of search results. When using the search control this is included in the search control logic "for free". If you are using a raw searcher, caputuring and presenting proper attribution is up to you. This method is designed to provide you with an attribution node (or null if no attribution is required) which you can then display appropriately. The display of attribution is only required while actively displaying a set of search results immeadiately after a search. The following snippet demonstrates a simple use of this API. var attribution = GlocalSearchgoogle.search.LocalSearch.getAttribution(); if (attribution) { var el = document.getElementById("searchwell"); el.appendChild(attribution); }
|
| This method allows the caller to set (or clear) an optional, additional query term that is appended to all queries flowing through the searcher. Applications will typically use this to the provide alternative results with mild variations from the original search term. For example, assuming a
|
| This method allows the caller to either create, or re-generate the
|
| After a search completes, a
|
| Static Method | Description |
|---|---|
| This method is a static helper function that you can use to proportionally scale an image. You pass in the width and height of the current image, as well as an imageScaler object (containing a .width and .height property) and the function will calculate and return a proportionally scaled imageScaler object. You can then use this object's .height and .width property to build an image element. Internally, the GvideoSearchgoogle.search.VideoSearch object defines an image scaler which it uses to scale the thumbnails. Its designed to maintain a 4x3 aspect ratio and is defined as follows.
// imageScaling defaults 4x3 100x75 image
this.imageScaler = {width:100,height:75};
When building the thumbnail // scale the thumbnail image using the searchers .imageScaler. // By default this is a 4x3 100x75 image, // but its settable using .setVideoResultsTbHeight as well var scaled = GSearchgoogle.search.Search.scaleImage(result.tbWidth, result.tbHeight, this.imageScaler); // scaled.height and scaled.width now contain // the values needed to proportionally scale the thumbnail
|
| This method is a static helper function that returns a "powered by Google" HTML DOM branding node to your application, and optionally attaches it to your document as the only child of the specified optional element. The purpose of this method is to ensure that your application has a simple way to comply with branding requirements in situations where using wither the search form in the The branding node, by default is designed for a horizontal orientation and works well underneath a search form, above or below a collection of results, etc. In some cases, a vertical orientation of the branding is needed. As an example of this, consider a vertically oriented Video Bar. In this case since the branding needs are so narrow, vertical orientation of the branding is needed (see the powered by Google branding at the bottom of the Video Bar). This API by default delivers horizontal orientation, but as an application, you can easily request vertical.
|
| This method is a static helper function that registers the specified handler function to be called once the document containing this call loads. Previous documentation recomended that you use the body element's onload attribute (e.g.,
|
The following collection of public properties are exposed by all objects that implement this interface. Unless otherwise stated, these properties are assumed to be read-only.
| Property | Description |
|---|---|
| This property contains an array of search result objects, one for each result. Each time a search executes, this property is cleared, and each time a search completes, the array is populated. If there are no results to report, the |
| This optional property is present once a search completes successfully. It is not present for Local and Blog search since those searchers do not currently support pagination. When present, the property specifies how an application can request additional search results for the current query term, the estimated result count, the current page, and the url that can be used to vector to a search results page hosted at Google. The property has the following structure:
|
This object implements the GSearchgoogle.search.Search interface over the Google Web Search service. Upon completion of a search it delivers a collection GwebResult objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Web Search service. |
| Method | Description |
|---|---|
| This method is used to restrict the set of web search results returned by this searcher. To restrict to www.amazon.com, simply call this method passing in a value of "www.amazon.com". To clear site restrictions, pass in a value of var siteSearch = new GwebSearchgoogle.search.WebSearch(); siteSearch.setSiteRestriction("amazon.com"); This method also allows the caller to restrict searches to a Google Custom Search Engine. Instead of specifying a URL path to this method, pass in the Custom Search Engine ID. The following snippet demonstrates setting a site restriction to a custom search engine whose id is var siteSearch = new GwebSearchgoogle.search.WebSearch(); siteSearch.setSiteRestriction("000455696194071821846:reviews"); When used in this manner, an optional Custom Search Engine Refinement may be supplied using the var cseId = "017576662512468239146:omuauf_lfve"; var siteSearch = new GwebSearchgoogle.search.WebSearch(); siteSearch.setSiteRestriction(cseId, "Lectures"); Custom search engines often include a customized search results landing page. In order to support this, when Custom Search Engine site restrictions are in effect, an optional The latest addition to Custom Search Engines is the ability to use Linked Custom Search Engines. In order to support this, the
When either
searcher = new google.search.WebSearch();
searcher.setSiteRestriction(
{
crefUrl : "http://www.google.com/cse/samples/vegetarian.xml"
},
"recipes");
|
| This method is used to specify or clear a restriction on the set of results returned by this searcher. In order to establish a restriction, both
var searcher = new google.search.WebSearch();
searcher.setRestriction(google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_OFF);
|
This object implements the GSearchgoogle.search.Search interface over the Google Local Search service. Upon completion of a search it delivers a collection GlocalResult objects.
This object is designed to produce search results relative to a geographic region. The object provides an API that allows applications to scope this geographic region by supplying a location string (city/state, a zipcode, an address), or by providing a GLatLnggoogle.maps.LatLng() object (see Google Maps), or by providing a GMap2google.maps.Map2() object (see Google Maps). The preferred interface is either a GLatLnggoogle.maps.LatLng() or a GMap2google.maps.Map2(). You may have noticed in the samples the presence of a "set location" control in the stack of local search results. This UI is implemented through coordination between the search control, and this object. The map projected through the search control scopes all search results, and its initial value (center point) is established by programming this object. The search control does not maintain preferences on center point. This is the responsibility of the application using this API.
Note: If no location is specified, this object scopes search results to the San Francisco, CA area. A more elaborate default is certainly being considered, something that takes into account the geographic region of the user.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Local Search service. |
| Method | Description |
|---|---|
| This method establishes a center point that is used to scope search results. It accepts a single variant which may be a string, a
|
| The default behavior of this searcher is to co-mingle address lookup results (e.g., NY, NY) with local search results. There are situations where this co-mingled approach is not the desired behavior. For instance, suppose the searcher is centered in Santa Barbara, CA and the user is searching for "Cava". With co-mingled results, the first search result is actually an address match against "Cava Close, Aberdeen City, AB15 UK". The second result is "Cava Restaurant & Bar". Using this method, applications are able to disable and enable address lookup producing either strictly search results, or address lookup results co-mingled with search results. In this case, if address lookup is disabled, the first result would be "Cava Restaurant & Bar".
|
| This method is used to specify or clear a restriction on the set of results returned by this searcher. In order to establish a restriction, both This API currently supports the following restriction types:
This method accepts the following arguments:
|
| Static Method | Description |
|---|---|
| This utility function is designed to resize the image associated with the
var img = document.createElement("img");
google.search.LocalSearch.resizeStaticMapUrl(result, 80, 120);
img.src = result.staticMapUrl;
img.title = result.titleNoFormatting;
|
| This utility function is designed to create a static map image from the caller supplied collection of points. The points may be in the form of a collection of search result objects, a collection of objects containing a numeric
// demonstrate computeStaticMapUrl with simple point array
this.worldPointsUrl = google.search.LocalSearch.computeStaticMapUrl(
worldPoints,350, 400);
document.getElementById("resultsImg").src =
this.worldPointsUrl;
...
var worldPoints = [
{ lat : 48.8565, lng : 2.3509 }, // paris
{ lat : 52.5238, lng : 13.4119}, // berlin
{ lat : 52.3738, lng : 4.8909}, // amsterdam
{ lat : 55.676294, lng : 12.568115}, // copenhagen
{ lat : 60.160791, lng : 24.952548}, // helsinki
{ lat : 59.332725, lng : 18.064454}, // stockholm
{ lat : 59.913820, lng : 10.738741} // oslo
];
|
This object implements the GSearchgoogle.search.Search interface over the Google Video Search service. Upon completion of a search it delivers a collection GvideoResult objects.
It is important to note that this searcher is designed to access both YouTube and Google Video. For the most part, the differences in the result format and player are minimal. In some cases, applications, through specialized query predicates can directly access YouTube Channels and Special Feeds. The following YouTube only query predicates are supported
| Predicate | Description |
|---|---|
ytchannel:name-of-channel expression? | The |
ytfeed:top_rated[.this_week | .this_month | .all_time] | The |
ytfeed:{most_viewed, recently_featured}[this_week | .this_month | .all_time] | The |
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Web Search service. |
| Method | Description |
|---|---|
| The default behavior of this searcher is to return results ordered by their relevance. In some cases, it is useful to see results ordered by date. This method may be used to change the result order.
|
This object implements the GSearchgoogle.search.Search interface over the Google Blog Search service. Upon completion of a search it delivers a collection GblogResultgoogle.search.BlogResult objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Blog Search service. |
| Method | Description |
|---|---|
| This method is used to restrict the set of blog search results returned by this searcher. To restrict results to all blog results on blogspot.com, simply call this method with a value of "blogspot.com". To restrict results to the Nintendo DS blog on Live Journal, simply call with "http://community.livejournal.com/nintendo_ds/". To clear site restrictions, pass in a value of
|
| The default behavior of this searcher is to return results ordered by their relevance. In some cases, it is useful to see results ordered by date. This method may be used to change the result order.
|
This object implements the GSearchgoogle.search.Search interface over the Google News service. Upon completion of a search it delivers a collection GnewsSearchgoogle.search.NewsResult objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google News service. |
| Method | Description |
|---|---|
| This method is used to restrict the set of news search results returned by this searcher. To restrict results to all news results from the Seattle Times, simply call this method with a value of "Seattle Times". To restrict results to results from CNN, simply call with "CNN". The pattern is that the title of the news source is seperated by either spaces or underscore (e.g., "_"). To clear site restrictions, pass in a value of
|
| The default behavior of this searcher is to return results ordered by their relevance. In some cases, it is useful to see results ordered by date. This method may be used to change the result order.
|
This object implements the GSearchgoogle.search.Search interface over the Google Book Search service. Upon completion of a search it delivers a collection GbookResult objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Book Search service. |
| Method | Description |
|---|---|
| This method is used to specify or clear a restriction on the set of results returned by this searcher. In order to establish a restriction, both This API currently supports the following restriction types:
|
This object implements the GSearchgoogle.search.Search interface over the Google Image Search service. Upon completion of a search it delivers a collection GimageSearchgoogle.search.ImageSearch objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Image Search service. |
| Method | Description |
|---|---|
| This method is used to specify or clear a restriction on the set of results returned by this searcher. In order to establish a restriction, both This API currently supports the following restriction types:
var searcher = new google.search.ImageSearch();
searcher.setRestriction(google.search.ImageSearch.RESTRICT_IMAGETYPE,
google.search.ImageSearch.IMAGETYPE_FACES);
searcher.setRestriction(google.search.ImageSearch.RESTRICT_FILETYPE,
google.search.ImageSearch.FILETYPE_JPG);
searcher.setRestriction(google.search.ImageSearch.RESTRICT_COLORIZATION,
google.search.ImageSearch.COLORIZATION_GRAYSCALE);
searcher.execute('Carmen Electra');
|
| This method is used to restrict the set of image search results returned by this searcher. To restrict to www.photobucket.com, simply call this method passing in a value of "www.photobucket.com". To clear site restrictions, pass in a value of var siteSearch = new GimageSearchgoogle.search.ImageSearch(); siteSearch.setSiteRestriction("photobucket.com"); |
This object implements the GSearchgoogle.search.Search interface over the Google Patent Search service. Upon completion of a search it delivers a collection GpatentResultgoogle.search.PatentResult objects.
| Constructor | Description |
|---|---|
| The constructor is used to create an instance of a searcher object designed to provide search results from the Google Patent Search service. |
| Method | Description |
|---|---|
| This method is used to specify or clear a restriction on the set of results returned by this searcher. In order to establish a restriction, both This API currently supports the following restriction types:
|
| The default behavior of this searcher is to return results ordered by their relevance. In some cases, it is useful to see results ordered by date. This method may be used to change the result order.
|
Result objects are produced using a JSON encoding of server search requests. As a result, we have chosen not to implement formal Javascript objects, and instead dynamically create these objects from their serialized form. While there is no formal implementation of the objects, they exist, and we document them as if there was a backing Javascript implementation. The impact of all this is minimal. All that it means is that there is no named constructor. For each result, its as if the system called new Object() and then proceeded to set formal properties on that object. The results are documented below in terms of their properties.
For all objects, there are two common properties:
.GsearchResultClass - specifies the type of result.html - supplies the root of an html element that may be cloned and attached somewhere into the applications DOM hierarchy. The .html property discussed above is built with CSS styling in mind. As a result, each piece of semantic information is enclosed in HTML markup with an appropriate set of class markers. This allows you to use this HTML in conjunction with your own custom CSS rules that style the HTML to meet your needs.
As you will see in the sections that follow, each search result is enclosed in a div element marked with a generic search result class of gs-result, as well as a result type specific class e.g., gs-webResult, gs-localResult, etc. This structure allows you to easily define generic CSS rules that are applied to all results, as well as type specific rules.
In addition to this structure, when a result is managed by the GSearchControlgoogle.search.SearchControl, each result is enclosed in a div element marked with a generic search control result class of gsc-result, as well as a result type specific class e.g., gsc-webResult, gsc-localResult, etc. Each section of results is further wrapped in a div element marked with a generic search control results class of gsc-results, as well as a result type specific class e.g., gsc-webResult, gsc-localResult, etc.
The net result of this structure is the following skeleton:
<!-- A collection of web search results in the search control -->
<div class="gsc-results gsc-webResult">
<!-- A single web result in the search control -->
<div class="gsc-result gsc-webResult">
<!-- A single web result, full structure defined below -->
<div class="gs-result gs-webResult"></div>
</div>
...
</div>
<!-- Similar pattern for local, blog, etc. -->
<div class="gsc-results gsc-localResult"></div>
<div class="gsc-results gsc-blogResult"></div>
| Common Property | Description |
|---|---|
| Indicates the "type" of result.
|
| Supplies the root of an html element that may be cloned and attached somewhere into the applications DOM hierarchy. We expect that this is the primary property that applications will be concerned with and that their typical interaction will involve cloning this node an attaching it into their DOM hierarchy. We expect that they will use css to control styling and to control which elements are displayed. For instance, we expect the following fragment to be common across all applications that wish to copy and past search results delivered through the Google AJAX Search API. // clone the .html node from the result var node = result.html.cloneNode(true); // attach the node into my dom container.appendChild(node); |
This object is produced by the GwebSearchgoogle.search.WebSearch object. It is available in that object's .results[] array, and may also be delivered through a search control's "keep callout" method.
This object is indicated by a .GsearchResultClass value of GwebSearchgoogle.search.WebSearch.RESULT_CLASS.
In addition to the common properties described above, the following object specific properties are available.
| Property | Description |
|---|---|
| Supplies the raw URL of the result |
| Supplies an escaped version of the above URL |
| Supplies a shortened version of the URL associated with the result. Typically displayed in green, stripped of a protocol and path. |
| Supplies the title value of the result |
| Supplies the title, but unlike .title, this property is stripped of html markup (e.g., <b>, <i>, etc.) |
| Supplies a brief snippet of information from the page associated with the search result |
| Supplies a url to google's cached version of the page responsible for producting this result. This property may be null indicating that there is no cache, and it might be out of date in cases where the search result has been saved and in the mean time, the cache has gone stale. For best results, this property should not be persisted. |
The following fragment of HTML illustrates the structure of a Web Search result's .html property. The purpose of this skeleton is to show you the major structural components so that you can alter the styling and display of a result. For instance, if you want to supress the "snippet", a CSS rule of #mycontrol .gs-webResult .gs-snippet { display : none; } would do the trick.
<div class="gs-result gs-webResult">
<!-- Note, a.gs-title can have embedded HTML
// so make sure to account for this in your rules.
// For instance, to change the title color to red,
// use a rule like this:
// a.gs-title, a.gs-title * { color : red; }
-->
<div class="gs-title">
<a class="gs-title"></a>
</div>
<div class="gs-snippet"></div>
<!-- The default CSS rule has the -short URL visible and
// the -long URL hidden.
//
// If you want to reverse this, use a rule like:
// #mycontrol .gs-webResult .gs-visibleUrl-short { display:none; }
// #mycontrol .gs-webResult .gs-visibleUrl-long { display:block; }
-->
<div class="gs-visibleUrl gs-visibleUrl-short"></div>
<div class="gs-visibleUrl gs-visibleUrl-long"></div>
</div>
This object is produced by the GlocalSearchgoogle.search.LocalSearch object. It is available in that object's .results[] array, and may also be delivered through a search control's "keep callout" method.
This object is indicated by a .GsearchResultClass value of GlocalSearchgoogle.search.LocalSearch.RESULT_CLASS.
In addition to the common properties described above, the following object specific properties are available.
| Property | Description |
|---|---|
| Supplies the title for the result. In some cases, the title and the streetAddress are the same. This typically occurs when the search term is a street address such as 1231 Lisa Lane, Los Altos, CA. |
| Supplies the title, but unlike .title, this property is stripped of html markup (e.g., <b>, <i>, etc.) |
| Supplies a url to a Google Maps Details page associated with the search result |
| Supplies the latitude value of the result. This may be used to construct a |
| Supplies the longitude value of the result. This may be used to construct a |
| Supplies the street address and number for the given result. Note:, in some cases, this property may be set to "" if the result has no known street address. address line. |
| Supplies the city name for the result. Note:, in some cases, this property may be set to "". |
| Supplies a region name for the result (e.g., in the us, this is typically a state abbreviation, in other regions it might be a province, etc.) Note:, in some cases, this property may be set to "". |
| Supplies a country name for the result. Note:, in some cases, this property may be set to "". |
| Supplies an array of phone number objects where each object contains a |
| Supplies a url that can be used to provide driving directions from the center of the set of search results to this search result. Note, in some cases this property may be missing or null. Always wrap access within a a test of |
| Supplies a url that can be used to provide driving directions from a user specified location to this search result. Note, in some cases this property may be missing or null. Always wrap access within a a test of |
| Supplies a url that can be used to provide driving directions from this search result to a user specified location. Note, in some cases this property may be missing or null. Always wrap access within a a test of |
| Supplies a url to a static map image representation of the current result. The image is 150px wide by 100px tall with a single marker representing the current location. Expected usage is to hyperlink this image using the |
| This property indicates the type of this result which can either be |
| For "kml" results, this property contains a content snippet associated with the KML result. For "local" results, this property is the empty string. |
The following fragment of HTML illustrates the structure of a Local Search result's .html property. The purpose of this skeleton is to show you the major structural components so that you can alter the styling and display of a result. For instance, if you want to supress the "address", a CSS rule of #mycontrol .gs-localResult .gs-address { display : none; } would do the trick.
<div class="gs-result gs-localResult">
<!-- Note, a.gs-title can have embedded HTML
// so make sure to account for this in your rules.
// For instance, to change the title color to red,
// use a rule like this:
// a.gs-title, a.gs-title * { color : red; }
-->
<div class="gs-title">
<a class="gs-title"></a>
</div>
<!-- Note, ONLY present for "kml" results -->
<div class="gs-snippet"></div>
<div class="gs-address">
<div class="gs-street"></div>
<div class="gs-city"></div>
<div class="gs-region"></div>
<div class="gs-country"></div>
</div>
<div class="gs-phone"></div>
<!-- This element provides driving directions from
// the center point location to this result. This
// is the default setting.
-->
<div class="gs-directions">
<a class="gs-directions"></a>
</div>
<!-- This element provides driving directions to/from the search result
// with the user supplying the starting/ending point (based on the link
// they clicked on). This is an alternate link. If you want this behavior
// instead of the default, use a set of rules similar to this:
//
// #mycontrol .gs-directions { display : none; }
// #mycontrol .gs-directions-to-from { display : block; }
//
// Directions here are provided in the form of:
//
// Get directions: To here - From here
-->
<div class="gs-directions-to-from">
<div class="gs-label"></div>
<div class="gs-secondary-link">
<a class="gs-secondary-link"></a>
</div>
<div class="gs-spacer"></div>
<div class="gs-secondary-link">
<a class="gs-secondary-link"></a>
</div>
</div>
</div>
This object is produced by the GvideoSearchgoogle.search.VideoSearch object. It is available in that object's .results[] array, and may also be delivered through a search control's "keep callout" method.
This object is indicated by a .GsearchResultClass value of GvideoSearchgoogle.search.VideoSearch.RESULT_CLASS.
In addition to the common properties described above, the following object specific properties are available.
| Property | Description |
|---|---|
| Supplies the title of the video result. |
| Supplies the title, but unlike .title, this property is stripped of html markup (e.g., <b>, <i>, etc.) |
| Supplies a snippet style description of the video clip |
| Supplies the url of a playable version of the video result |
| Supplies the published date of the video (rfc-822 format) |
| Supplies the name of the video's publisher, typically displayed in green below the video thumbnail, similar to the treatment used for visibleUrl in the other search result objects. |
| The approximate duration, in seconds, of the video |
| Supplies the width in pixels of the video thumbnail |
| Supplies the height in pixels of the video thumbnail |
| Supplies the url of a thumbnail image which visually represents the video. |
| If present, supplies the url of the flash version of the video that can be played inline on your page. To play this v |