Export (0) Print
Expand All

GeocodeRequestOptions Object

Bing

Contains the options for a geocode request.

Properties

Name Type Description

bounds

LocationRect

A location rectangle that defines the boundaries of the area in which to search for location results. The default is the bounds of the map view associated with this instance of the SearchManager, which is usually the current map view.

callback

function

The name of the function to call when a successful result is returned from the geocode request. The callback function must accept two parameters: result, which is a GeocodeResult type, 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 error callback function must accept a GeocodeRequestOptions object.

timeout

number

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

userData

Object

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

where

string

A string containing the address or place to be matched to a location on the map. Required.

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 geocodeRequest = {where:"1 Microsoft Way, Redmond, WA", count:10, callback:geocodeCallback, errorCallback:errCallback};
         searchManager.geocode(geocodeRequest);
      }
     
      function geocodeCallback(geocodeResult, userData)
      {
         alert("The first geocode result is " + geocodeResult.results[0].name + ".");
      }


      function errCallback(geocodeRequest)
      {

         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