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
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 ).
That sounds like a case for TurfJS:
- find two points of the road that are nearest to the location
- use pointToLineDistance, where line is a line created by these two points from the road, and the point is the location provided
This will work great.