[OpenLayers-Dev] Text placement of features in vector layer

Ringdahl Niklas Niklas.Ringdahl at sweco.se
Mon Oct 26 10:20:17 EDT 2009


Hi list.

I would like to have more control on the label placement, using features with labels on a vector layer. 

I have several features added to a vector layer, rendering in SVG. I use the style attribute "label" to set a label text for the point, and the "labelAlign" attribute to set the alignment. But I don't feel that the "labelAlign" property is doing what I want, I would like more control of where my label ends up. So I looked into the SVG specification and the DOM elements created by OpenLayers for my features and labels and found the "dx" and "dy" attributes, which don't seem to be used in OpenLayers renderers. Is this a design decision or is it just an area which noone have looked into?

What I would like to do is to be able to set the SVG specific properties, like "dx" and "dy" on the tspan element, to fine tune the placement of the labels. Are there any more possibilities to control this than using the "labelAlign" today? 

If there is some kind of documentation of the label handling out there that I haven't found, I would be happy to be pointed in the right direction.

Thanks!
- Niklas


More information about the Dev mailing list