开发者

Bing Maps Route Service CalculateRoute returns "An error occurred while processing the request."

I've written a Silverlight class to consume the Bing Maps Routing Service. I'm creating an array of Waypoint objects from lat/long data that I have stored in a database, and sending that to the CalculateRoute method of the webservice in order to get a route back, but I am unable to successfully get a route back. The response always contains the error "An error occurred while processing the request." I'm stumped. Any ideas about how I could solve this or at least get a more helpful error/exception out of the service? Here's the method that calls the service:

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

I then have a callback that handles the response, but I h开发者_如何学编程ave been unable to get a successful response. I've tried making sure the maxBufferSize and maxReceivedMessageSize are set correctly and that timeouts are set correctly, but to no avail. Any help would be much appreciated.


It appears that this line:

request.Options.TrafficUsage = TrafficUsage.TrafficBasedRouteAndTime;

was the culprit. Apparently if you've got that option set and request a route for somewhere that doesn't have traffic data, it dies rather than just ignoring it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜