c# - Windows Phone 8.1 应用程序中的 routeResult.Status 不断给出无效凭据错误消息

标签 c# xaml windows-phone-8.1

我是 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/

相关文章:

css - 来自 Bootstrap 的魔术字体大小

windows-phone-7 - 如何通过浏览器 url 启动 windows phone 应用程序

xaml - 删除 Windows Phone 8.1 应用程序中的数据透视项中的空格

c# - WPF寻找方法来创建带有文本标签框架的边框

c# - 无法从传输连接 IMAP 读取数据

c# - 如何遍历 ChartColorPalette 属性并添加到列表?

c# - 这个正则表达式是什么意思 - "\p{Lu}"?

.net - 在选项卡之间移动时如何阻止 WPF 验证错误消失?

c# - Windows Phone 上的 WriteableBitmap 高速绘图

c# - NAudio WaveStream 和多 channel