When a user deviates from the planned route, I am having trouble calculating an appropriate reroute. The calculateRoute service does not take into account the user's heading direction.
I am attempting to implement the rerouting feature myself using JavaScript. Initially, I calculate a route based on the start and destination locations provided.
If the user strays from the planned route, I need to reroute them by calculating a new route to guide them back to their intended destination. I have only been able to use the calculateRoute service for this purpose, but I am encountering a problem.
For example, in a scenario where a user is supposed to take the first exit in a roundabout but mistakenly takes a wrong exit, my rerouting logic detects the deviation and calculates a new route based on the user's current location and the destination point. However, the issue arises when the user is heading north but the calculated route instructs them to make an illegal u-turn to reach the intended destination since the calculateRoute service does not consider the heading angle.
Please advise if there are any alternative methods to properly calculate a reroute in a JavaScript/REST API platform.