[GIS] How to individually label points in Openlayers linestring

labelinglinestringopenlayers

I want to display some text below each point on a linestring with Openlayers. The text would include, for example, the coordinates of the point, plus some other information.

I have managed to add a style to these points, but so far only the same style to all.

https://jsfiddle.net/wainwrightalex/6qbpqmme/8/

I considered creating a new feature for each point, but I would like to avoid this if possible, so I can still use ol.interaction.Modify to edit the linestring.

Is it possible to somehow style these points individually? Or add individual text in some other way?

Best Answer

You can use the geometry config option of ol.style.Style and use a function to create a point at every vertex (http://openlayers.org/en/v3.5.0/apidoc/ol.style.html#GeometryFunction)

See also this blog post for some related information: http://boundlessgeo.com/2015/04/geometry-based-styling-openlayers-3/

Related Question