简体   繁体   中英

How to add infobox to a waypoint in bing maps

how can I add infobox to waypoint in bing maps.I am unable to find which event or object having option to add infobox to bing map.

Here is sample code from microsoft site I am using.

 function getMap()
  {
      map = new Microsoft.Maps.Map(document.getElementById('myMap'),
          {
              credentials: 'bing map key',
          });
       createDirections();
  function createDrivingRoute()
  {
    if (!directionsManager) { createDirectionsManager(); }
    directionsManager.resetDirections();
    directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });
    var seattleWaypoint = new Microsoft.Maps.Directions.Waypoint({ address: 'Seattle, WA' });
    var TukwilaWaypoint = new Microsoft.Maps.Directions.Waypoint({ address: 'Tukwila, WA' });
    directionsManager.addWaypoint(seattleWaypoint);
    directionsManager.addWaypoint(TukwilaWaypoint);
    var tacomaWaypoint = new Microsoft.Maps.Directions.Waypoint({ address: 'Tacoma, WA', location: new Microsoft.Maps.Location(47.255134, -122.441650) });
    directionsManager.addWaypoint(tacomaWaypoint);
    // Set the element in which the itinerary will be rendered
    directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('directionsItinerary') });
    alert('Calculating directions...');
    directionsManager.calculateDirections();
  }

  function createDirections() {
    if (!directionsManager)
    {
      Microsoft.Maps.loadModule('Microsoft.Maps.Directions', { callback: createDrivingRoute });
    }
    else
    {
      createDrivingRoute();
    }
  }
    }

You can add events to the DirectionsManager that will first after the steps have rendered and then us the information to add your infoboxes. Take a look at the afterStepRender, afterWaypointRender, and the afterSummaryRender events: https://msdn.microsoft.com/en-us/library/hh312802.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM