You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

基于Bing Maps Web Control API规划路线时能否忽略交通状况?

Great question! Yes, you absolutely can configure the Bing Maps Web Control API to ignore real-time traffic conditions—including temporary road closures—while still offering users route options based on highway/non-highway preferences. Let’s break down how to implement this:

Configuring Bing Maps to Ignore Traffic

1. Disable Traffic Usage

The core setting to bypass real-time traffic data is the trafficUsage parameter in your route request options. Setting this to disabled tells the API to calculate routes using only the static base road network, ignoring all live disruptions like temporary closures, accidents, or congestion.

2. Define Route Type Preferences

To retain highway/non-highway route options for users, use the routeType property. You can pass an array of route profiles here to offer choices like fastest (highway-focused), shortest, or scenic (non-highway prioritized).

Example Implementation Code

Here’s a practical code snippet showing how to set this up:

// Initialize your map
const map = new Microsoft.Maps.Map('#mapContainer', {
    credentials: 'YOUR_BING_MAPS_API_KEY'
});

// Create a Directions Manager instance
const directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);

// Configure route request options
directionsManager.setRequestOptions({
    // Disable traffic entirely
    trafficUsage: Microsoft.Maps.Directions.TrafficUsage.disabled,
    // Offer multiple route types (adjust based on your needs)
    routeType: [
        Microsoft.Maps.Directions.RouteType.fastest,
        Microsoft.Maps.Directions.RouteType.shortest,
        Microsoft.Maps.Directions.RouteType.scenic
    ]
});

// Add origin and destination waypoints
const origin = new Microsoft.Maps.Directions.Waypoint({ address: 'New York, NY' });
const destination = new Microsoft.Maps.Directions.Waypoint({ address: 'Boston, MA' });
directionsManager.addWaypoint(origin);
directionsManager.addWaypoint(destination);

// Trigger route calculation
directionsManager.calculateDirections();

Key Notes to Remember

  • When trafficUsage is set to disabled, the API won’t factor in any real-time road changes—routes will strictly follow the static road layout.
  • The routeType array lets you present users with distinct route options. For non-highway routes, scenic is a great choice if you want to prioritize local roads over interstates.
  • Ensure your Bing Maps API key has the necessary permissions for the Directions service (most standard keys include this by default).

内容的提问来源于stack exchange,提问作者Michael Witt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 07:48:40