line.closestPointNormalizedLength(p)

Return the normalized length (distance from the start of the line / total line length) of the closest point laying on the line to the point p.