Bing Maps v8 - 如何使用DirectionsManager模块设置公差(tl)或将其删除?

时间:2016-09-30 14:04:29

标签: maps bing bing-api bing-maps

下面的代码会自动生成一个URL jsonp来调用Bing Maps REST API。但公差参数由模块定义。如何定义要发送的自定义容差?

  

容差参数(由模块定义): tl:4.5263499577364666e-7,0.0000036210799661891733,0.000028968639729513386,0.0002317491178361071,0.0018539929426888567,0.014831943541510854,0.11865554833208683

     

完整网址(由模块生成): https://dev.virtualearth.net/REST/v1/Routes/driving?key=AuohX_nFB0n9SozQUluVxFiJ3lHUMgNWDxt29NLz0fwqCKBZ32QJOwuh1lhtKaLK&o=json&jsonp=Microsoft.Maps.NetworkCallbacks.f98696&c=pt-BR&fi=true&wp.0=47.67683029174805,-122.1099624633789&wp.1=47.59977722167969,-122.33458709716797&tl=4.5263499577364666e-7,0.0000036210799661891733,0.000028968639729513386,0.0002317491178361071,0.0018539929426888567,0.014831943541510854,0.11865554833208683&optmz=timeWithTraffic&du=km&dt=9/30/2016%2010:54:00&tt=departure&maxSolns=3&rpo=Points

var map = new Microsoft.Maps.Map(document.getElementById('myMap'), {
   credentials: 'Your Bing Maps Key',
   center: new Microsoft.Maps.Location(47.606209, -122.332071),
   zoom: 12
});

Microsoft.Maps.loadModule('Microsoft.Maps.Directions', function () {
    var directionsManager = new Microsoft.Maps.Directions.DirectionsManager(map);

    // Set Route Mode to driving
    directionsManager.setRequestOptions({ routeMode: Microsoft.Maps.Directions.RouteMode.driving });

    var waypoint1 = new Microsoft.Maps.Directions.Waypoint({ address: 'Redmond', location: new Microsoft.Maps.Location(47.67683029174805, -122.1099624633789) });
    var waypoint2 = new Microsoft.Maps.Directions.Waypoint({ address: 'Seattle', location: new Microsoft.Maps.Location(47.59977722167969, -122.33458709716797) });

    directionsManager.addWaypoint(waypoint1);
    directionsManager.addWaypoint(waypoint2);

    // Set the element in which the itinerary will be rendered
    directionsManager.setRenderOptions({ itineraryContainer: document.getElementById('printoutPanel') });
    directionsManager.calculateDirections();
});

Bing Maps DirectionsManager文档: https://msdn.microsoft.com/en-US/library/mt748655.aspx

1 个答案:

答案 0 :(得分:0)

您无法设置公差,也无需设置公差。默认设置中的最小容差值将返回路由服务为路由提供的所有坐标。如果有的话,我会看看我是否可以将所有公差值一起移除,因为自创建方向功能以来V8形状的性能已大幅提升。