VEMap.FindLocations 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 for locations that match a VELatLong input.

VEMap.FindLocations(veLatLong, callback);

Parameters

Parameter Description

veLatLong

A VELatLong Class object that specifies what map location to match.

callback

The name of the function that the server calls when it returns search results.

Return Value

This method does not return a value. The function defined by the callback parameter receives one argument from the server:

  • An array of VEPlace Class objects. If the search is unsuccessful, this argument is null. Otherwise, these objects represent the possible location matches.

Remarks

The VEMap.FindLocations method is only supported in the United States.

Example

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

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

      <script type="text/javascript">
         var map = null;
         var locations = null;
         var pixel = null;
         var clickEvent = null;
         var LL = null;

         function GetMap()
         {
            map = new VEMap('myMap');
            map.LoadMap();

            map.AttachEvent("onclick", PixelClick);

         }

         function PixelClick(e)
         {
        var x = e.mapX;
            var y = e.mapY;
            pixel = new VEPixel(x, y);
            LL = map.PixelToLatLong(pixel);

            map.FindLocations(LL, GetResults);

         }


         function GetResults(locations)
         {
            var s="Results for " + LL.Latitude + ", " + LL.Longitude + ": ";
            if(locations)
            {
           for(var i=0;i<locations.length;i++)
               {
                 s+=locations[i].Name;

               }
            }
            else
            {
               s+='No Result found.';
            } 

            alert(s);
         }

      </script>
   </head>
   <body onload="GetMap();">
      <div id='myMap' style="position:relative; width:600px; height:400px;"></div>
      <br>Click on the map to display location information.<br/>
   </body>
</html>

See Also

Reference

VEMap.Find Method

Concepts

VELatLong Class