首页 > 解决方案 > TimeType ARRIVAL 在 Android SDK 中不起作用

问题描述

我希望我的用户能够在出发和到达时间之间切换。但是,当我在 routeOptions.setTime 中使用 TimeType.ARRIVAL 发送路由计划请求时,它会给我一个 INVALID_PARAMETERS 错误。但是与 TimeType.DEPARTURE 完全相同的请求可以正常工作。

下面是我的代码。我做错了什么还是 TimeType.ARRIVAL 已被弃用或只是不工作?

   RoutePlan routePlan = new RoutePlan();

    RouteOptions routeOptions = new RouteOptions();
    routeOptions.setTransportMode(RouteOptions.TransportMode.PUBLIC_TRANSPORT);
    routeOptions.setRouteType(RouteOptions.Type.FASTEST);
    routeOptions.setRouteCount(3);
    routeOptions.setLocale(Locale.getDefault());
    if (toggleSwitch.getCheckedTogglePosition() == 0) {
        routeOptions.setTime(selected_time, RouteOptions.TimeType.DEPARTURE);
    }
    else {
        routeOptions.setTime(selected_time, RouteOptions.TimeType.ARRIVAL);
    }
    routePlan.setRouteOptions(routeOptions);

    // Select Waypoints for your routes
    routePlan.addWaypoint(new RouteWaypoint(start_address_coordinate));
    routePlan.addWaypoint(new RouteWaypoint(end_address_coordinate));
    router.calculateRoute(routePlan, new RouterListener());

标签: here-api

解决方案


根据HERE 文档

仅 UMRouteOptions 支持到达时间类型选项。在 RouteOptions.setTime(Date, TimeType) 中使用此值,以及不受支持的 RouteOptions,将在请求路由时导致 RoutingError.INVALID_PARAMETERS。

因此,您得到的错误是预期的行为。请根据HERE 文档更正您的代码。


推荐阅读