Monday, 19 March 2018

labeling - Split label style in GeoServer CSS or SLD


I would like to split the style of my labels, which consist of 2 attributes. I already managed to separate the lines, but I need to style them differently as well, as the second line should be bold.


Currently my map looks like this:


how it looks like


And I would like it to look like this:


how it should look like


I would prefer to do it in CSS, but I also prepared the style in SLD, so I would be happy for a solution in either of them.


My code looks like this in CSS:


* {
label: [IDENT][LOWERLIMIT];

-gt-label-auto-wrap: 1;
font-weight: normal;
font-fill: black;
}

and like this in SLD:






black
normal




Answer




Here is a solution in SLD but I think you should be able to generate the same in CSS.


enter image description here


The trick is to use 2 TextSymbolizers and offset them so that they don't overlap.


     



Arial

Normal
10




0.5
1.0




0


10










Arial Bold
Normal
bold
10





0.5
0.0



0



-10






Depending on your font and polygon sizes you can play with the AnchorPoints and Displacements to adjust the exact placement of the labels.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...