I'm having a list of points (coordinates + extra info). I want to show them on the map as LineString and when I hover a vertex/point I want to get a callback where I display extra info for the given point. As the list could be big I don't want to create a feature for each point, but just one for the LineString. Otherwise I end up in performance problems. I can easily take the closest point from the LineString, but it's just coordinates, without any identification ... index would be sufficient.
Here is how my code looks like:
var geometry = new ol.geom.LineString(positions);
map.on("pointermove", function(event)
{
if (event.dragging) { return; }
var mouseCoordinates = map.getEventCoordinate(event.originalEvent);
var closestPoint = geometry.getClosestPoint(mouseCoordinates);
console.log(closestPoint);
});