What do you need from a preprocessed MapLibre style editor?
Posted by pnorman on 19 April 2025 in English.It’s difficult to write in all map style languages. A style written in JSON, like MapLibre, has a few extra pain points because JSON is not designed for editing by humans.
Some “common” style languages are
- CartoCSS
- Mapnik XML
- MapCSS
- MapServer
- MapLibre GL/Mapbox GL
Some, like CartoCSS, are designed for human editing, while others, like Mapnik XML, serve as a lower-level language. MapLibre GL falls into this category of not being designed for editing by humans. MapLibre GL preprocessors like glug were designed to help with this, but none of them have taken off. Other style projects like openstreetmap-americana have taken a different route. Their developers have written a program in JavaScript that generates the style.
I’m taking a different route. I’m creating a language that uses minimal pre-processing of its input to produce MapLibre GL. I don’t aim to solve every difficulty with MapLibre GL, only the ones that impact me the most. The end result will be a pre-processing language
The biggest problems I encounter when writing MapLibre GL are
-
No comments
Comments are essential so other readers understand what’s written
-
Everything has to be in one file.
With large styles this is a burden. More than one file makes it easier to edit.
-
Having to repeat definitions instead of using a variable.
Something like a color or symbol definition might appear a dozen times in the style. If you want to change it, you need to make sure you got all the occurrences.
-
Inability to make versions of the style in different colors.
When you only want to change a few superficial elements of the style, you want to contain those changes to one file.
-
Not having support for more colorspaces
I work in perceptual colorspaces like Lch. It’s a lot of converting that the computer should automate.
What issues have you found when writing MapLibre GL styles?