0

We are converting Android Project Here Map Android Starter SDK to Lite Edition. I want to display the multiple waypoints on route.

For Starter SDK we are using the RoutePlan for plotting the multiple waypoints. but in Lite Edition i am unable to find the RoutePlan. For more information find the below Android Starter SDK Code snippets:

    val routePlan = RoutePlan()
    val routeOptions = RouteOptions()
    routeOptions.transportMode = RouteOptions.TransportMode.CAR
    routeOptions.routeType = RouteOptions.Type.FASTEST

    routePlan.routeOptions = routeOptions

   for (routeLatLang in tripRouteData) { 
                try {
                    routePlan.addWaypoint(GeoCoordinate(lat.toDouble(), longg.toDouble()))
                } catch (e: Exception) {
                    e.printStackTrace()
                }
    }

    val error = routeManager.calculateRoute(routePlan, routeManagerListener)
    if (error != RouteManager.Error.NONE) {
        Toast.makeText(activity,
                "Route calculation failed with: " + error.toString(), Toast.LENGTH_SHORT)
                .show()
    }

Also find the below code snippets of Lite Edition SDK :

    val waypoint1 = Waypoint(latitude1,longitude1)
    val waypoint2 = Waypoint(latitude2,longitude2)
    val waypoints = java.util.ArrayList(Arrays.asList(Waypoint(startGeoCoordinates),
            waypoint1, waypoint2, Waypoint(destinationGeoCoordinates)))

So, How we can plot the multiple waypoints on Here Map Lite Edition, Also what is limit of maximum waypoints to plot on route.

Nitin Karande
  • 1,280
  • 14
  • 33

2 Answers2

2

It's a different SDK. Having a look at the feature list, you'll find that directions are supported. Thus you'll have to look at the documentation to figure out how it works.

Eventually you'll have to do something like:

routingEngine.calculateRoute(
        waypoints,
        new CarOptions(),
        new CalculateRouteCallback() {
            @Override
            public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List<Route> routes) {
                if (routingError == null) {
                    Route route = routes.get(0);
                    showRouteDetails(route);
                    showRouteOnMap(route);
                } else {
                    showDialog("Error while calculating a route:", routingError.toString());
                }
            }
        });
tynn
  • 38,113
  • 8
  • 108
  • 143
1

The new SDK 4.x (Lite) has some different concepts and features than classic Starter SDK, so it's not a full drop in replacement.

For routing, things are quite similar, you can check out the github example for exactly your case here:

https://github.com/heremaps/here-sdk-examples/blob/master/examples/android/Routing/app/src/main/java/com/here/routing/RoutingExample.java

In a short:

RouteEngine still exists, but within the calculateRoute method you pass in a list of waypoints (first one is start, last one is end, everything in between are stopover or pass-through waypoints).

See : https://developer.here.com/documentation/android-sdk/api_reference/com/here/sdk/routing/RoutingEngine.html#calculateRoute-java.util.List-com.here.sdk.routing.CarOptions-com.here.sdk.routing.CalculateRouteCallback-

Marco
  • 2,190
  • 15
  • 22