2015-08-21 43 views
0

我有類似的問題,如This question,但它只出現在某些方向上並非全部。Win RT windows phone 8.1 MapControl:MapRouteFinder.GetDrivingRouteAsync返回一些引腳的InvaldiCredentials狀態

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; 

在上面的代碼中routeResult.Status將返回invalidCredentials的,但只有在某些方面不適合所有點。

回答

1

您需要在調用MapRouteFinder.GetDrivingRouteAsync方法之前設置Map Service令牌。在調用此函數之前添加以下行代碼,並確保添加您的Map服務標記。

MapService.ServiceToken = "Your Maps Service Token"; 

如果不添加此項,該應用程序可能會對某些座標有點隨意。

相關問題