In a google map, I have drawn a route with 2 coordinates say (x1, y1) and (x2, y2). Now if we consider a coordinate as (a,b), how can we determine if that coordinated belongs to the route drawn.
X1 - Latitude Y1 - Longitude
I have tried line equation for this, however it is failing.
public static bool AmIOnTheLine(Point start, Point end, Point location)
{
////Line equation
var slope = (start.Y - end.Y) / (start.X - end.Y);
//y = mx + b
//b is y intercept
double yIntersect = start.Y - slope * start.X;
var result = slope * location.X + yIntersect;
if(result == location.Y)
return true;
return false;
}
I have multiple paths drawn on a map.