Why don't you use turf.js in conjunction with mapbox-gl-js?
E.g. you could calculate the distance to the line with http://turfjs.org/docs/#pointToLineDistance for each point, then filter out any points with a distance bigger than 0.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…