Search code examples
routeshere-api

Here API returning very poorly constructed routes for transit


I am trying to use the Here API for my transit app. My target is to find an efficient transit plan for point A to point B. I was trying, for example, to find a route from Trafalgar Square (coordinates 51.5080° N, 0.1281° W) to Madam Tussauds (51.5230° N, 0.1544° W). So, this is the URL I tried:

https://router.hereapi.com/v8/routes?transportMode=pedestrian&origin=51.5308,0.12&destination=51.5323,0.15&return=summary&apiKey=myKey

In response I get a very poorly constructed route, with just two sections - one for origin and one for destination. Same goes when I try car in place of pedestrian. In contrast, when I use Google, for example, I get a detailed route, saying "Go from A to B for 500 metres, turn right at Torrington Palace, walk for 400 metres, cross the street to Paddington Avenue", etc.

enter image description here

Is there any way to get a similarly rich route information for place A to B with Here APIs?


Solution

  • The maneuver details in routing V8 are returned by specifying the following parameters in the request.

    return=polyline,actions,instructions
    

    The structured information about the actions needed to complete the route can be obtained by specifying return=polyline,actions when requesting a route. This may be useful when providing user interface elements such as the position or icon for an action.

    Instructions may be included in an action by specifying return=polyline,actions,instructions when requesting the route. Instructions provide a textual description of the action that is appropriate for end-users.

    Example Request:

    https://router.hereapi.com/v8/routes?
    origin=51.5080,0.1281&
    transportMode=car&
    destination=51.5230,0.1544&
    return=polyline,actions,instructions,summary&
    apikey=<API KEY>
    

    Response: enter image description here

    The request can be mocked up here: https://refclient.ext.here.com/#url=https://router.hereapi.com/v8/routes?origin=51.5080,0.1281&transportMode=car&destination=51.5230,0.1544&return=polyline,actions,instructions,summary&apikey=SQJ15KMgNuP6jvYPiLSG_-aics8s7f55XPwOhSfXeYM

    Documentation Link: https://developer.here.com/documentation/routing-api/dev_guide/topics/use-cases/actions.html