line.closestPointLength(point)

Return the length of the line up to the point that lies closest to point.