我是 XAML 编程的新手,我正在使用 MapControl 在 Windows Phone 8.1 模拟器上申请学校作为作业。
昨天我想画一条路线并按照这个教程http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631250.aspx ,而且效果很好。今天我再次运行它,但它一直给我错误消息 'InvalidCredentials' 和 routeResult.Status。我不知道为什么会出现此错误。
这是我使用的代码:
public async void SetRouteDirectionsBreda()
{
string beginLocation = "Willemstraat 17 Breda";
string endLocation = "Reigerstraat 2 Breda";
MapLocationFinderResult result = await MapLocationFinder.FindLocationsAsync(beginLocation, map.Center);
MapLocation begin = result.Locations.First();
result = await MapLocationFinder.FindLocationsAsync(endLocation, map.Center);
MapLocation end = result.Locations.First();
List<Geopoint> waypoints = new List<Geopoint>();
waypoints.Add(begin.Point);
// Adding more waypoints later
waypoints.Add(end.Point);
MapRouteFinderResult routeResult = await MapRouteFinder.GetWalkingRouteFromWaypointsAsync(waypoints);
Debug.WriteLine(routeResult.Status); // DEBUG
if (routeResult.Status == MapRouteFinderStatus.Success)
{
MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
viewOfRoute.RouteColor = Colors.Blue;
viewOfRoute.OutlineColor = Colors.Black;
map.Routes.Add(viewOfRoute);
await map.TrySetViewBoundsAsync(routeResult.Route.BoundingBox, null, MapAnimationKind.Bow);
}
else
{
throw new Exception(routeResult.Status.ToString());
}
}
最佳答案
您应该在 xaml 页面中添加您的 map 服务 token ,并将您的应用程序 ID 添加到包 list 中。
关于将 mapservicetoken 添加到您的应用程序,您需要了解的所有信息都可以在下面的链接中找到。 http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn741528.aspx
关于c# - Windows Phone 8.1 应用程序中的 routeResult.Status 不断给出无效凭据错误消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27757642/