TransWikia.com

Using CSS var function in GeoServer CSS styling

Geographic Information Systems Asked on April 21, 2021

I wanted to check if I could use something like the CSS var() function with the GeoServer CSS plugin styles.
Something to look like:

    :root {
        --land-color: #f2efe9;
      }
    /* @title Land */
    [featurecla = 'Land'] {
        background-color: var(land-color);
      }

Except obviously for more than one variable.
I came across this question but could not get the only suggested solution there to work.
This is what I tried:

/* &env=land-color:#dd0000 */
/* @title Land */
[featurecla = 'Land'] {
fill: env('land-color');
stroke: #f2efe9;
}

EDIT

The result I want to get is setting a color (or any other style variable, like halo-radius or font-size) once and the use it by name in entire stylesheet, making it easier to edit it across the document.

I keep getting a default white polygon with black stroke when using this. The CSS validates properly but does nothing.

One Answer

GeoServer CSS does not support the var function, or setting variables at the beginning of the stylesheet.

Code changes to add such support, or funding to make that happen, are both gratefully accepted.

Answered by Andrea Aime on April 21, 2021

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