0

I have same problem like This question but it occurs only for some directions not for all.

MapPB.IsIndeterminate = true;
    MapPB.Visibility = Visibility.Visible;
    Geopoint destGeopoint = new Geopoint(new BasicGeoposition() { Latitude = Convert.ToDouble(location.Latitude), Longitude = Convert.ToDouble(location.Longitude) });

                             MapRouteFinderResult routeResult = await MapRouteFinder.GetDrivingRouteAsync(MyGeopoint, destGeopoint, MapRouteOptimization.Distance, MapRouteRestrictions.None);

                             if (routeResult.Status == MapRouteFinderStatus.Success)
                             {
                                 // Use the route to initialize a MapRouteView.
                                 MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
                                 viewOfRoute.RouteColor = App.ApplicationThemeColor;
                                 viewOfRoute.OutlineColor = App.ApplicationThemeColor;

                                 // Add the new MapRouteView to the Routes collection
                                 // of the MapControl.
                                 MapControl1.Routes.Clear();
                                 MapControl1.Routes.Add(viewOfRoute);

                                 // Fit the MapControl to the route.
                                 await MapControl1.TrySetViewBoundsAsync(
                                     routeResult.Route.BoundingBox,
                                     null,
                                     Windows.UI.Xaml.Controls.Maps.MapAnimationKind.None);
                             } 

                         MapPB.IsIndeterminate = false;
                         MapPB.Visibility = Visibility.Collapsed;

In above code routeResult.Status is returning InvalidCredentials but only on some points not for all points.

Community
  • 1
  • 1
Yawar
  • 1,924
  • 3
  • 29
  • 39

1 Answers1

1

You need to set the Map Service Token before calling the MapRouteFinder.GetDrivingRouteAsync method. Add the following line code before calling this function and be sure to add your Map service token.

MapService.ServiceToken = "Your Maps Service Token";

If you don't add this, the app may work for some coordinates a bit randomly.

rbrundritt
  • 16,570
  • 2
  • 21
  • 46