g.polyline.closestPoint(point)

Return a point on the polyline that is the closest to the given point.