【问题标题】:routeResult.Status in windows phone 8.1 app keeps giving invalidcredentials errormessageWindows Phone 8.1 应用程序中的 routeResult.Status 不断给出无效凭据错误消息
【发布时间】:2015-01-06 19:17:48
【问题描述】:

我是 XAML 编程的新手,我正在使用 MapControl 在 windows phone 8.1 模拟器上申请学校作为作业。

昨天我想画一条路线,按照这个教程http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn631250.aspx,效果很好。今天我再次运行它,但它不断给我带有 routeResult.Status 的错误消息“InvalidCredentials”。我不知道为什么会出现这个错误。

这是我使用的代码:

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

【问题讨论】:

    标签: c# xaml windows-phone-8.1


    【解决方案1】:

    您应该在 xaml 页面中添加您的地图服务令牌,并将您的应用程序 ID 添加到包清单中。

    您需要了解的有关将 mapservicetoken 添加到您的应用程序的所有信息都可以在下面的链接中找到。 http://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn741528.aspx

    【讨论】:

    • 我真的必须购买代币才能真正使用它吗?有一天它工作得很好......
    • 看起来学生代币是免费的!谢谢!
    • 我有同样的问题,添加了每个令牌和 ID,并且仅在某些位置出现此错误,其他工作并显示路线也
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    相关资源
    最近更新 更多