Elzar
Elzar is a Python compiler that turns declarative style definitions into Mapbox GL style JSON, with native Go bindings for sprite generation.
It powers the map styles served by Woosmap.
Features
Declarative style tree
Define styles using dot-separated selectors (road.highway.motorway) that inherit from their parents. Change a color at road.highway and every child road type picks it up.
SDF sprite generation
Generate recolorable sprite sheets from SVG icons using a Go-native bin-packer. Icons use SDF rendering so icon-color and icon-halo-color work at runtime — including a dual-color trick for two-tone icons like road shields.
Style diff
Compare two style JSONs at the property level — see exactly which paint/layout/filter values changed, not just which layers were added or removed.
Multiple variants
Streets classic, satellite hybrid, and next-gen styles share the same generator and source data, with per-variant color palettes and layer configs.
Fully typed
Strict mypy, Pydantic v2 models for the entire Mapbox GL spec, zero Any types.
Quick start
# Install
make env
# Build native sprite library
make lib
# Generate the classic streets style
python -m map_style generate --style=streets -o style/streets_classic.json
# Generate with sprite sheet
python -m map_style generate --style=streets -o style/streets.json --generate-sprite
# Compare two styles
python -m map_style diff style/streets.json style/streets_classic.json
Project structure
| Package | Description |
|---|---|
map_style/generator/ |
Core rendering engine — style tree, layer renderer, Mapbox GL types, sprite bindings |
map_style/streets_classic/ |
Classic streets style definition |
map_style/streets_satellite/ |
Satellite hybrid style |
map_style/streets_next/ |
Next-gen style (WIP) |
map_style/diff.py |
Structural style comparator |
sprite/ |
Go sprite generator (compiled to ctypes shared lib) |
Next steps
- Getting started — install, build, generate
- CLI usage —
generateanddiffsubcommands - Creating styles — define custom map styles
- Sprite generation — SVG to SDF sprite pipeline
- Style diff — property-level style comparison
- Building wheels — cross-platform distribution