[OpenLayers-Users] Label Middle of Line

Jürgen Dankoweit Juergen.Dankoweit at T-Online.de
Fri Jul 19 20:32:20 PDT 2013


Hello,

Am 19.07.2013 19:19, schrieb boesiii:
> I am trying to add a label for a line and would like the label to display at
> the midpoint.  It looks like this isn't available OOTB.  Does anyone have
> some code samples they wold like to share?


A possible solution is the following:
First set the attribute of the style/styleMap "labelAlign" to the value "cm"
Then use the function "getCentroid" from the geometry object to
calculate the center point of the line.

I hope this helps you.

Best regards

Juergen


> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
> 


-- 
Meine stets unfertige Homepage: www.dankoweit.de


More information about the Users mailing list