0

大约一周前,我开始遇到“响应解析问题”来使用 Android Premium SDK 计算自定义路由(适用于任何地方)。我使用相同的代码有一段时间了,但最近出现了这个错误。所以,我无法计算任何地方的自定义路线......

我查看了开发者网站,可以看到文档将 3.18 版本指向最新的 SDK 版本,但我只能在我的面板上下载 3.17 版本。是问题吗?他们发布了另一个 API 并且与以前的版本不兼容?如果是这样,我在哪里可以下载新版本?

我自己的一点代码:

    FTCRRouteOptions routeOptions = new FTCRRouteOptions();
    routeOptions.setTransportMode(FTCRRouteOptions.TransportMode.CAR);
    routeOptions.setRouteType(FTCRRouteOptions.Type.SHORTEST);
    routeOptions.setUseTraffic(true);

    FTCRRoutePlan routePlan = new FTCRRoutePlan(waypoints, routeOptions);

    try {
        FTCRRouter.Listener routerListener = new FTCRRouter.Listener() {
            @Override
            public void onCalculateRouteFinished(@NonNull List<FTCRRoute> list, @NonNull FTCRRouter.ErrorResponse errorResponse) {
                if (errorResponse.getErrorCode() == RoutingError.NONE) {
                    if (list != null && list.size() > 0) {

                        route = list.get(0);

                        manobras = route.getManeuvers();

                        traduzir(manobras.get(0).getInstruction());

                        mapRoute = new FTCRMapRoute(route);
                        mapRoute.setColor(Color.rgb(34, 162, 229));
                        map.addMapObject(mapRoute);

                        gbb = route.getBoundingBox();
                        map.zoomTo(gbb, Map.Animation.NONE, Map.MOVE_PRESERVE_ORIENTATION);

                        pontoCentral = new PointF(map.getTransformCenter().x, (map.getTransformCenter().y * 85 / 50));
                        map.setTransformCenter(pontoCentral);

                        Image icone = new Image();
                        marcadorNavegacao = new MapMarker();

                        try {
                            icone.setImageResource(R.mipmap.pngegg);
                            marcadorNavegacao.setIcon(icone);
                        } catch (IOException ioe) {

                        }

                        mapFragment.getPositionIndicator().setVisible(false);
                        map.setCenter(waypoints.get(0).getNavigablePosition(), Map.Animation.NONE);
                        map.setZoomLevel(25, Map.Animation.NONE);
                        marcadorNavegacao.setVisible(true);
                        marcadorNavegacao.setCoordinate(map.getCenter());
                        map.addMapObject(marcadorNavegacao);

                        circulo = new MapCircle();
                        if (rotaAtual != null || rotasFiltradas != null) {
                            if (rotaAtual == null) {
                                rotaAtual = rotasFiltradas.get(0);
                            }

                            rotaEstatica = rotaAtual;

                            circulo.setCenter(map.getCenter());
                            circulo.setRadius(rotaAtual.SeqRaio);
                            circulo.setLineColor(Color.RED);
                            circulo.setFillColor(Color.argb(30, 255, 0, 0));
                            map.addMapObject(circulo);
                        }

                        tvRuaAtual.setVisibility(View.VISIBLE);
                        ivManobra.setVisibility(View.VISIBLE);
                        tvProximaRua.setVisibility(View.VISIBLE);
                        tvDistanciaProximaManobra.setVisibility(View.VISIBLE);
                        tvEmSeguida.setVisibility(View.VISIBLE);
                        ivProximaManobra.setVisibility(View.VISIBLE);

                        map.getMapTransitLayer().setMode(MapTransitLayer.Mode.EVERYTHING);
                        map.getMapTrafficLayer().setEnabled(MapTrafficLayer.RenderLayer.INCIDENT, true);

                        startingNavigation();

                    } else {
                        Toast.makeText(context, "Rota não encontrada", Toast.LENGTH_LONG).show();
                    }
                } else {

                    if (errorResponse.getErrorCode() == RoutingError.VIOLATES_OPTIONS) {
                        Toast.makeText(getApplicationContext(), "Erro interno na HERE. Não é possível prosseguir", Toast.LENGTH_LONG).show();
                    } else {
                        try {
                            if (progressDialog != null) {
                                progressDialog.cancel();
                            }

                            Toast.makeText(context, "Erro ao calcular rota: " + errorResponse.getMessage(), Toast.LENGTH_LONG).show();

                            navegacaoAssistida(inicio, termino, waypoints);
                        } catch (Exception e) {

                        }
                    }
                }
            }
        };

        coreRouter.calculateRoute(routePlan, routerListener);
    } catch (
            Exception ex) {
        Log.e("CoreRouter", ex.getLocalizedMessage());
    }
4

0 回答 0