Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

SearchRequestOptions Object

Bing

Contains options for a search request.

Properties

Name Type Description

callback

function

The name of the function to call when a successful result is returned from the search request. The callback function must accept two parameters: a result, which is a SearchResponse, and a userData object.

count

number

The maximum number of results to return. Required. The maximum number than can be returned is 20.

errorCallback

function

The name of the function to call when the request is returned with an error. The callback function must accept a SearchRequestOptions object.

query

string

The search string, such as “pizza in Seattle, WA”. Either query or what/where needs to be specified. If both are specified, an error occurs.

startIndex

number

The index of the first result in the results. For example, if you had already returned a first set of 10 search results and now wanted to return the second set of 10 results, you would specify 10 as the startIndex and 10 as the count.

timeout

number

A number indicating how long to wait, in seconds, for the search request to return. The default value is 5 seconds.

entityType

string

The type of entities to find. Currently only “Business” is allowed.

userData

Object

An object containing any data that needs to be passed to the callback when the request is completed.

what

string

The business name, category, or other item for which the search is conducted. For example, “pizza” in the search string “pizza in Seattle”.

where

string

The address or place name of the area for which the search is conducted. For example, “Seattle” in the search string “pizza in Seattle”.

Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
   <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

      <script type="text/javascript" src="http://ecn.dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=7.0"></script>

      <script type="text/javascript">

      var map = null;

      function GetMap()
      {  

         map = new Microsoft.Maps.Map(document.getElementById("mapDiv"), {credentials: "Bing Maps Key", center: new Microsoft.Maps.Location(47.5, -122.3), zoom: 9 });

         Microsoft.Maps.loadModule('Microsoft.Maps.Search', { callback: searchModuleLoaded });

      }


      function searchModuleLoaded()
      {
         var searchManager = new Microsoft.Maps.Search.SearchManager(map);

         var searchRequest = {what:"pizza", where:"Seattle", count:10, callback:searchCallback, errorCallback:searchError};
         searchManager.search(searchRequest);
      }
     
      function searchCallback(searchResponse, userData)
      {
         alert("The first search result is " + searchResponse.searchResults[0].name + ".");
      }


      function searchError(searchRequest)
      {
         alert("An error occurred.");
      }
      
      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:600px; height:600px;"></div> 
   </body>
</html>

See Also

Show:
© 2015 Microsoft