Any way for checking given location point is on route or not or near to it

Is there any way for checking whether the given location point is on route or not or near to it (for example point is at 200 meters like that)? -> In my project, One user will find a route from A to B, and then I want to calculate the shortest distance of the given(User’s own location) location point from the route not from the start or end location of route

1 Like

Hi.

As far as I know, there is no such functionality in JS SDK, but on the other hand, having the route coordinates, it shouldn’t be hard to check whether your point is near to your route or not ( once you’ll define what near or being on route exactly means ).

Regards,
Mateusz

3 Likes

That sounds like a case for TurfJS:
https://turfjs.org/docs/#pointToLineDistance

  1. find two points of the road that are nearest to the location
  2. use pointToLineDistance, where line is a line created by these two points from the road, and the point is the location provided
3 Likes

Thanks,
This will work great.