Search code examples
here-api

How to avoid the motorway road in Here map API query


I want to avoid the motorway road when calculate the route between the start and destination

https://router.hereapi.com/v8/routes?transportMode=car&motorway:-1&origin=52.120066,11.570918&destination=52.282376,6.687846&return=travelsummary,polyline&apikey=<key>

But above query doesn't work, it not avoid the motorway

Refer documents:https://developer.here.com/documentation/routing/dev_guide/topics/resource-param-type-routing-mode.html

And I already check their is possibility of the route, to avoid the motorway.

https://www.google.com/maps/dir/'52.120066,11.570918'/'52.282376,6.687846'/@52.3407684,7.9868359,8z/data=!3m1!4b1!4m12!4m11!1m3!2m2!1d11.570918!2d52.120066!1m3!2m2!1d6.687846!2d52.282376!2m1!1b1!3e0


Solution

  • As per the Routing v8 documentation the proper parameter to avoid all highways is avoid[features]=controlledAccessHighway instead of motorway:-1

    https://router.hereapi.com/v8/routes?transportMode=car&avoid[features]=controlledAccessHighway&origin=52.120066,11.570918&destination=52.282376,6.687846&return=travelsummary,polyline&apikey=..

    Note: probably better value to use is tollRoad as it allows highways without tolls (e.g. in Germany)