我编写了一个Silverlight类来使用Bing Maps Routing Service。我正在从存储在数据库中的lat / long数据创建一个Waypoint对象数组,并将其发送到webservice的CalculateRoute方法以获取路由,但我无法成功获取路由。响应始终包含错误“处理请求时发生错误”。我很难过。有关如何解决这个问题或者至少从服务中获得更有用的错误/异常的任何想法?以下是调用服务的方法:
public void CalculateRoute(Waypoint[] waypoints)
{
request = new RouteRequest();
request.Waypoints = new ObservableCollection<Waypoint>();
for (int idx = 0; idx < waypoints.Length; idx++)
{
request.Waypoints.Add(waypoints[idx] as Waypoint);
}
request.ExecutionOptions = new ExecutionOptions();
request.ExecutionOptions.SuppressFaults = true;
request.Options = new RouteOptions();
request.Options.Optimization = RouteOptimization.MinimizeTime;
request.Options.RoutePathType = RoutePathType.Points;
request.Options.Mode = TravelMode.Walking;
request.Options.TrafficUsage = TrafficUsage.TrafficBasedRouteAndTime;
_map.CredentialsProvider.GetCredentials(
(Credentials credentials) =>
{
request.Credentials = credentials;
RouteClient.CalculateRouteAsync(request);
});
}
然后我有一个处理响应的回调,但我无法得到成功的响应。我已经尝试确保正确设置了maxBufferSize和maxReceivedMessageSize,并且正确设置了超时,但无济于事。任何帮助将不胜感激。
答案 0 :(得分:0)
看来这一行:
request.Options.TrafficUsage = TrafficUsage.TrafficBasedRouteAndTime;
是罪魁祸首。显然,如果您已经设置了该选项并为没有流量数据的某个地方请求路由,那么它就会消失而不是忽略它。