0

I am trying to display real-time traffic information on Here maps along my route. However it doesn't seem to be showing up on the route that I have selected but it shows up in other places. Could someone shed some light on this issue? I have also attached screenshots of my application.Screenshot 1 Screenshot 2

private void createRoute(RouteOptions.TransportMode transportMode, GeoCoordinate startCoodinate, GeoCoordinate endCoodinate) {

       CoreRouter coreRouter = new CoreRouter();
       RoutePlan routePlan = new RoutePlan();
       RouteWaypoint startPoint = new RouteWaypoint(startCoodinate);
       RouteWaypoint destination = new RouteWaypoint(endCoodinate);
       routePlan.addWaypoint(startPoint);
       routePlan.addWaypoint(destination);

       RouteOptions routeOptions = new RouteOptions();
       routeOptions.setTransportMode(transportMode);
       routeOptions.setHighwaysAllowed(false);
       routeOptions.setRouteType(RouteOptions.Type.SHORTEST);
       routeOptions.setRouteCount(1);
       routePlan.setRouteOptions(routeOptions);

       trafficUpdater = TrafficUpdater.getInstance();
       trafficUpdater.enableUpdate(true);

       TrafficUpdater.GetEventsListener myGetEventsListener = new TrafficUpdater.GetEventsListener() {
           @Override
           public void onComplete(List<TrafficEvent> trafficEvent, TrafficUpdater.Error error) {

               if (error == TrafficUpdater.Error.NONE) {
                   // how to use the callback trafficEvent to affect m_mapRoute ?????

               } else {

               }
           }
       };

       TrafficUpdater.Listener myTrafficUpdaterListener = new TrafficUpdater.Listener() {
           @Override
           public void onStatusChanged(TrafficUpdater.RequestState requestState) {
               if (requestState.equals(TrafficUpdater.RequestState.DONE)) {
                   trafficUpdater.getEvents(m_mapRoute.getRoute(), myGetEventsListener);
               }
           }
       };

       CoreRouter.Listener myCoreRouterListener = new CoreRouter.Listener() {
           @Override
           public void onProgress(int i) {
               /* The calculation progress can be retrieved in this callback. */

           }

           @Override
           public void onCalculateRouteFinished(List<RouteResult> routeResults, RoutingError routingError) {
               if (routingError == RoutingError.NONE) {
                   if (routeResults.get(0).getRoute() != null) {
                       m_mapRoute = new MapRoute(routeResults.get(0).getRoute());
                       trafficUpdater.request(m_mapRoute.getRoute(), 100, myTrafficUpdaterListener);
                       m_map.addMapObject(m_mapRoute);
                       m_mapRoute.setRenderType(MapRoute.RenderType.SECONDARY);
                       GeoBoundingBox gbb = routeResults.get(0).getRoute()
                               .getBoundingBox();
                       m_map.zoomTo(gbb, Map.Animation.NONE, Map.MOVE_PRESERVE_ORIENTATION);
                   } else {
                       Toast.makeText(m_activity,
                               “Error:route results returned is not valid”,
                               Toast.LENGTH_LONG).show();
                   }
               } else {
                   Toast.makeText(m_activity,
                           “Error:route calculation returned error code: ” + routingError,
                           Toast.LENGTH_LONG).show();
               }
           }

       };

       coreRouter.calculateRoute(routePlan, myCoreRouterListener);
   }

The results of the info that I am getting back is given below:

Traffic flow message.
Event Text: Traffic flow message.
Short Text: FLOW
Severity: HIGH
Affected Streets: [Norra Vallgatan]
Affected Length: 500
From Streets: [Hamngatan]
To Streets: [Slottsgatan]
Speed Limit: 17
Flow: True
Incident: False
Visible: True
Penalty: 0
HIGH
17
Norra Vallgatan

That is the callback result from calling TrafficUpdater.GetEventsListener

Edit: I've included the coordinates below:

address  =[Triangeln ],
start location =[Lat: 55.61151575555467, Long: 12.994461363051823, Alt: 0.0],
end   location =[Lat: 55.59671, Long: 13.00098, Alt: 1.073741824E9]

address  =[Gothenburg ],
start location =[Lat: 55.61163785303746, Long: 12.994434358214308, Alt: 0.0],
end   location =[Lat: 57.70068, Long: 11.96823, Alt: 1.073741824E9]

Hope someone can help!

vish
  • 1
  • 1
  • Please share your route start and end coordinates for us to help you better. –  Oct 24 '18 at 13:47

1 Answers1

0

Disable Traffic Auto Update and also request traffic updates only on your route like shown below. In your code you have requested for traffic updates in and around 100 meters radius of your route. That could be a reason.

map.disableTrafficAutoUpdate();
trafficUpdater.request(mapRoute.getRoute(), myTrafficUpdaterListener);