Export (0) Print
Expand All

NearbyVenue Class

Bing

Defines a nearby venue map.

Properties

Name Type Description

distance

double

The distance, in meters, to the venue.

metadata

Metadata

The venue map metadata.

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()
         {
            // Initialize the map and set the view to a specific location
            map = new Microsoft.Maps.Map(document.getElementById("mapDiv"),{credentials:"Bing Maps Key", center: new Microsoft.Maps.Location(47.6,-122.3), zoom:11}); 

            Microsoft.Maps.loadModule('Microsoft.Maps.VenueMaps', { callback: venuemapsModuleLoaded });

         }

         function venuemapsModuleLoaded()
         {
            // Create the venue map
            var vmaps = new Microsoft.Maps.VenueMaps.VenueMapFactory(map); 


            // Search for nearby venues
            vmaps.getNearbyVenues({map: map, location: map.getCenter(), radius:10000, callback:DisplayNearbyVenueCount});

         }


         function DisplayNearbyVenueCount(venues)
         {
            var displayResults = "Nearby venues with available venue maps:\n";

            for (var i=0; i<venues.length; i++)
            {
               displayResults = displayResults + venues[i].metadata.Name + "\t" + venues[i].distance/1000 + " km\n";

            }

            alert(displayResults);
         }


      </script>
   </head>
   <body onload="GetMap();">
      <div id='mapDiv' style="position:relative; width:500px; height:500px;"></div>       
   </body>
</html>
Show:
© 2014 Microsoft