How do I find the location on a polyline that is closest to another point on the map. For a visual of what I am looking for, in the attached PolylinePoint.png I want to obtain the yellow "Nearest Point' location.
The geometry task 'DistanceAsync' gets the closest distance between a polyline and point. However, I am looking for that 'Nearest Point' location.
This can be done easily by client side. Just use dist=Math.Square(a*a+b*b) to calculate every distance between your point and each point on the polyline, then you get the nearest point on the polyline.
The problem is I am looking for the nearest location on the polyline. The location may not contain a vertex. (see attached visual)
Looping through each vertice and using your forumla would give me the distance from each vertice. But, that is not what I am looking for.
The 'DistanceAsync' task gives me the distance, but for some reason I can't get the polyline nearest location. I would think the value for this would be exposed somewhere.
If the segment is a straight line (i.e. not an arc, ellipse, ...), it looks easy: - project the point on the line, - if the projected point is on the segment => it's the shortest distance - if not on the segment, thye shortest distance is given by the closest vertex.