2016-09-30 76 views
0

下面的代码自动生成一个URL jsonp来调用Bing Maps REST API。但容差参数由模块定义。我如何定义发送的定制容差? (由模块定义)Bing Maps v8 - 如何使用DirectionsManager模块设置公差(tl)或将其删除?

公差参数: TL:4.5263499577364666e-7,0.0000036210799661891733,0.000028968639729513386,0.0002317491178361071,0.0018539929426888567,0.014831943541510854,0.11865554833208683

完整URL(由模块生成):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 Docs: https://msdn.microsoft.com/en-US/library/mt748655.aspx

回答

0

您不能设置公差,也没有任何需要。默认设置中的最小公差值将返回路线服务为路线提供的所有坐标。如果有的话,我会去看看我能否将容差值全部去掉,因为V8形状的性能在创建方向功能后已经大大改善。

+0

感谢您的回复,但在我的情况下,公差会从我的itineraryItems对象中删除一些坐标。我需要所有坐标来计算距离路线每3公里的(lat,lng)位置,以添加图钉。 当我使用路线itineraryItems对象坐标时,距离计算器崩溃,当远处拖动点存在时 (例如:O ---- 3km ---- O ---- 3km ---- O --- - 3km ---- O) 你是否知道我从REST api jsonp response的DirectionsManager获取坐标? .resourceSets [“0”]。resources [“0”]。routePath.line.coordinates –

+1

行程项目和宽容无关。容差返回路径路径的多个分辨率。 V8目前不公开路径路径数据(仅绘制它)。这将在一两个月内的即将发布的更新之一中公开。如果您现在需要,可以直接调用REST API。你不会直接使用Directions manager来调用这个API。这是来自V7的代码示例,它直接调用REST服务。这将在第8版中起作用。 https://msdn.microsoft.com/en-us/library/gg427607.aspx – rbrundritt

+0

没错。这就是我所做的。非常感谢您的帮助! –