Topic: OnlineMapsUtils.NearestPointStrict, trying to get distance from route

Hey Alex,
I am trying to find the users distance from the route, so if the user gets a certain distance from the route (makes a wrong turn), i can trigger a re-calculation of the route from the users current GPS location. In this post ( you mentioned using OnlineMapsUtils.NearestPointStrict, however i could not find it in the API docs. could you explain how to use it? or if there is a better way?

I am already using distancebetweenpoints to display the next step instruction when the user is within 150 feet of the next point.

Also, OnlineMapsGoogleDirectionsResult.Step.distance returns a TextValue<int>, Does this mean I can just assign the returned value to an integer variable or is some conversion needed? I looked at the distance and duration example that uses this but i wasn't sure.

Thanks for your help!

Re: OnlineMapsUtils.NearestPointStrict, trying to get distance from route


OnlineMapsUtils.NearestPointStrict method is created for internal use in drawing API, so it is not documented.
But in this particular situation this method is very useful.

How it works:
You know that the user should be somewhere between points A and B.
You pass to the method the user's coordinates (U) and the coordinates of points A and B.
The method returns the coordinates of the point (C) on the segment AB, which is closest to U.
You calculate the distance between points C and U.
If the distance is more than 150 feet, you need to find a new route.
Example attached.

Yes, you can assign TextValue<int>.value to an integer variable.

Post's attachments

Attachment icon TurnByTurnNavi.cs 5.69 kb, 32 downloads since 2018-07-11 

Kind Regards,
Infinity Code Team

Re: OnlineMapsUtils.NearestPointStrict, trying to get distance from route

Thank you for reply, that clears it up! your the man.