I am using Google Direction API to plot the route path between 2 places A and B. I am able to do this. Now, I have a requirement to check if given a place C falls in the rou
You can use the geometry library that (you can request with google maps by changing your script src to https://maps.googleapis.com/maps/api/js?sensor=false&libraries=geometry
) and use isLocationOnEdge
and use the LatLng
of point C and the polyline that is returned from the DirectionsService
.
https://developers.google.com/maps/documentation/javascript/geometry#isLocationOnEdge
Then again, point C could ALWAYS be on the way between A and B if you added it as a waypoint, so determining if point C is "on the way" is actually a bit of a tricky concept - how far out of the way is too far for it to not be "on the way"?