VEMap.Search Method

You are not viewing the latest version of the AJAX control. Bing Maps AJAX V7 is the recommended JavaScript control for Bing Maps. If you need this documentation, it is available in as a CHM or PDF download.

Performs a search based on a given query and options.

VEMap.Search(query, callback, options);


Parameter Description


The string to use in the search.


The name of the function that the server calls with the search results.


A VESearchOptions Class object specifying additional options.

This method does not return a value. The function defined by the callback parameter receives the following arguments, in the order shown, from the server:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
      <title>VEMap.Search Method</title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

      <script type="text/javascript" src=""></script>

      <script type="text/javascript">
         var map     = null;
         function GetMap()
            map = new VEMap('myMap');

         function ClickSearch()
            map.Search(document.getElementById('txtQuery').value, findCallback);

         function findCallback(layer, findResults, placeResults, moreResults, error)
            var s='';
            if (placeResults != null)
               s += 'Where Results:\n'
               for (var i=0; i < placeResults.length; ++i)
                  s += 'Name: ' + placeResults[i].Name + '\n'; s+= 'LatLong: ' + placeResults[i].LatLong + '\n'; s+= 'MatchCode: ' + placeResults[i].MatchCode+ '\n'; s+= 'MatchConfidence: ' + placeResults[i].MatchConfidence+ '\n'; s += '\n\n';
            if (findResults != null)
               s += 'What Results:\n'
               for (var i=0; i < findResults.length; ++i)
                  s += 'Name: ' + findResults[i].Name + '\n'; s+= 'Description: ' + findResults[i].Description + '\n'; s+= 'Phone: ' + findResults[i].Phone + '\n'; s+= 'LatLong: ' + findResults[i].LatLong + '\n'; s += '\n\n';

   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <input id="txtQuery" type="text" value="coffee in Seattle"/>
      <input type="button" value="Search" onclick="ClickSearch()"/>