TransWikia.com

Tilemill/CartoCSS: how to center label in a polygon

Geographic Information Systems Asked by Vanuan on December 9, 2020

For some reason, labels are always placed in the bottom right of a polygon. I want them in the center of a polygon.

I tried these:

text-horizontal-alignment: middle;
text-vertical-alignment: middle;

but it doesn’t help.

Update:

I noticed a strange thing: buildin labels are centered inside a polygon, but for regular area=yes or landuse=yes they are along the line, i.e. text-placement:interior is not working consistently.

Full example:

#labels {
    text-name: "[name]";
    text-fill: #444;
    text-face-name: 'Alfios Bold';
    text-placement: interior;
    text-size: 12pt;
}

#cemetery[building='yes'] {
    polygon-fill: #0f0;
}

#cemetery[landuse='residential'] {
    polygon-fill: #0f0;
}

One Answer

I know this is an old question, but if someone stumbles upon it currently looking for the answer try

text-placement-type: simple;

Answered by JMers on December 9, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP