如何在bing map中添加信息框到一个航点

时间:2016-02-10 10:01:37

标签: javascript bing-api bing-maps

如何在bing maps中添加信息框到路标。我无法找到哪个事件或对象可以选择将信息框添加到bing map。

以下是我正在使用的微软网站的示例代码。

 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();
    }
  }
    }

1 个答案:

答案 0 :(得分:0)

您可以向DirectionsManager添加事件,这些事件将在呈现步骤后首先添加,然后使用信息添加信息框。看看afterStepRender,afterWaypointRender和afterSummaryRender事件:https://msdn.microsoft.com/en-us/library/hh312802.aspx