无法从 Bing maps .NET REST 工具包中返回的对象获取 RouteLegs

Cannot get RouteLegs from returned object in Bing maps .NET REST toolkit

我正在使用 Microsoft Bing Maps .NET REST 工具包。

我尝试这样的路由请求:

    private async Task<Resource[]> CallTruckAPI(string apiKey, int minutes, bool currentTraffic, List<SimpleWaypoint> waypoints)
    {
        string key = apiKey;

        var routeRequest = new RouteRequest()
        {
            Waypoints = waypoints,
            WaypointOptimization = TspOptimizationType.TravelTime,
            RouteOptions = new RouteOptions()
            {
                TravelMode = TravelModeType.Driving
            },
            BingMapsKey = key
        };

        var response = await routeRequest.Execute();

        return response.ResourceSets[0].Resources;
    }

它returns 资源集和我可以访问的资源。

但是当我尝试从资源中获取 RouteLegs 时,我无法在 C# 中获取任何内容。

我可以在 Visual Studio 中查看它们,正如您在上面看到的,但无法访问它们。有什么想法吗?

我想通了。对于返回的每个 Bing 资源,我需要将其转换为 Bing 路由。然后我可以得到包括 RouteLegs 在内的内容。

希望对大家有所帮助!