Route on map only shows direct line

Hi All, not sure if I posted in the right group.

Anyway I have a set of LatLnt (say 6 locations) and want to display the route on map. Instead of showing route it only shows the direct line between points. Are there anything I missed?

Code as below:

RouteDescriptor routeDescriptor = new RouteDescriptor.Builder()
.travelMode(TravelMode.CAR)
.considerTraffic(false)
.routeType(RouteType.SHORTEST)
.build();

        RouteCalculationDescriptor routeCalculationDescriptor = new RouteCalculationDescriptor.Builder()
                .routeDescription(routeDescriptor)
                .waypoints(waypoints)
                .sectionType(SectionType.CAR_TRAIN)
                .computeBestOrder(false)
                .routeRepresentation(RouteRepresentation.POLYLINE)
                .build();

        RouteSpecification routeSpecification = new RouteSpecification.Builder(
                waypoints.get(0), waypoints.get(waypoints.size() - 1))
                .routeCalculationDescriptor(routeCalculationDescriptor)
                .build();

        routingApi.planRoute(routeSpecification,routeCallback);
        RouteBuilder routeBuilder = new RouteBuilder(waypoints)
                .endIcon(Icon.Factory.fromResources(this, R.drawable.ic_map_route_start))
                .startIcon(Icon.Factory.fromResources(this, R.drawable.ic_map_route_end));

        final Route mapRoute = tomtomMap.addRoute(routeBuilder);

Edited: When I add debug message in callback, it gives me the following error messages:

E/OnlineRoutingApi: Planning route failed: Error in service response: Could not parse json. Error(offset 819200): Invalid value.

E/RouteResponseDecoder: Decode error: missing or invalid result member “sections” in “route”

E/OnlineRoutingApi: Planning route failed: Error in service response: Decode error: invalid result member “route” in “routes”.

Can someone explain more about this?
Thank you

Hi.

I can’t reproduce the same error as you, but indeed something is wrong with parsing the response when you are using a CAR_TRAIN parameter. When I’m switching to FERRY, it seems to be OK.
Is it possible for you to share the SDK version which you are using?

Regards,
Mateusz

At the end I use different code which I had other issue (in other post) which works instead of the online tutorial/document/example:

LatLng[] route = new LatLng[waypoints.size()-2]; // minus the start and end
for (int i=1;i<waypoints.size()-1;i++){
route[i-1]=waypoints.get(i);
}

        RouteQuery routeQuery = new RouteQueryBuilder(waypoints.get(0),waypoints.get(waypoints.size()-1))
                .withWayPoints(route)
                .withRouteType(RouteType.SHORTEST)
                .build();

        Icon startIcon  = Icon.Factory.fromResources(this,R.drawable.ic_map_route_departure);
        Icon endIcon = Icon.Factory.fromResources(this,R.drawable.ic_map_route_destination);
        routingApi.planRoute(routeQuery)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new DisposableSingleObserver<RouteResponse>() {
                               @Override
                               public void onSuccess(RouteResponse routeResponse) {
                                   dismissDialogInProgress();
                                   displayRoutes(routeResponse.getRoutes());
                                   tomtomMap.displayRoutesOverview();
                               }

                               private void displayRoutes(List <FullRoute> routes) {
                                   for (FullRoute fullRoute : routes) {
                                       tomtomMap.addRoute(new RouteBuilder(
                                               fullRoute.getCoordinates()).startIcon(startIcon).endIcon(endIcon));

                                   }
                               }

                               @Override
                               public void onError(Throwable e) {
                                   dismissDialogInProgress();
                                   Toast.makeText(getApplicationContext(),e.getLocalizedMessage(), Toast.LENGTH_LONG).show();

Log.w(“Route error”,"Error message "+e.getLocalizedMessage());
}
}
);