0

我正在开发一个具有地图功能的 UWP 应用程序。我有 Rout 绘图功能,但这个功能有问题。

这是我的代码(在 WP 8.1 中功能齐全)

public async Task DrawRouteOnMap(double StartLong, double StartLat, double EndLong, double EndLat)
    {
        // Start at Grand Central Station.
        BasicGeoposition startLocation = new BasicGeoposition();
        startLocation.Latitude = StartLat;
        startLocation.Longitude = StartLong;
        Geopoint startPoint = new Geopoint(startLocation);
        // End at Central Park.
        BasicGeoposition endLocation = new BasicGeoposition();
        endLocation.Latitude = EndLat;
        endLocation.Longitude = EndLong;
        Geopoint endPoint = new Geopoint(endLocation);
        // Get the route between the points.
        MapRouteFinderResult routeResult =
        await MapRouteFinder.GetDrivingRouteAsync(
          startPoint,
          endPoint,
          MapRouteOptimization.Distance,
          MapRouteRestrictions.None,
          290);

        if (routeResult.Status == MapRouteFinderStatus.Success)
        {
            // Use the route to initialize a MapRouteView.
            MapRouteView viewOfRoute = new MapRouteView(routeResult.Route);
            viewOfRoute.RouteColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);
            viewOfRoute.OutlineColor = Windows.UI.Color.FromArgb(1, 43, 151, 71);

            //await new Windows.UI.Popups.MessageDialog(viewOfRoute.Route.EstimatedDuration.ToString()).ShowAsync();
            // Add the new MapRouteView to the Routes collection
            // of the MapControl.
            mapControl.Routes.Add(viewOfRoute);
            // Fit the MapControl to the route.
            await mapControl.TrySetViewBoundsAsync(
              routeResult.Route.BoundingBox,
              null,
              MapAnimationKind.Linear);
        }
    }

这段代码的结果是

未找到起点

我也尝试过没有希望的静态位置。

提前致谢

4

0 回答 0