Is it possible to style labels in such a way that if two labels were to overlap each other, they could move out of each other's way and display next to each other instead of their original position?

For example, if by default a label is displayed in the center of a polygon, and two polygons have the same geometric center, only one of the two labels for those polygons would show (as they would have the same priority, one of the two labels is chosen at random). I'd like to style the labels in such a way that if this were to happen, both of the labels will display but they'd be displaced or offset slightly from the center so that they can both be displayed at the same time, without overlapping.

Is this possible? Relevant documentation: http://docs.geoserver.org/latest/en/user/styling/sld/reference/labeling#pointplacement


I found the answer to my problem with the "maxDisplacement" vendor option.

For lines, normally GeoServer labels a line at its center point only. If this label conflicts with another one it may not be displayed at all. When this option is enabled the labeller will attempt to avoid conflic by using an alternate location within maxDisplacement pixels along the line from the pre-computed label point.

For points this causes the renderer to start circling around the point in search of a empty stop to place the label, step by step increasing the size of the circle until the max displacement is reached. The same happens for polygons, around the polygon labelling point (normally the centroid).


<VendorOption name="maxDisplacement">10</VendorOption>

Geoserver documentation: http://docs.geoserver.org/latest/en/user/styling/sld/reference/labeling.html#maxdisplacement

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.