Drop the OsmAnd-recolor map theme, add offline labels and a lighter palette nudge
Remove osmand-style.js (the per-layer color-patching approach) and its docs entirely — back to the plain OpenFreeMap "liberty" style online, and protomaps-themes-base's stock theme offline as the base. Offline maps previously had no text labels at all: the protomaps-themes-base layers() call never passed a lang option, which is required to include its label layers. Fixed, backed by vendored Noto Sans Regular/Italic/Medium glyph PBFs (ranges 0-255 and 256-511 only — Basic Latin + Latin-1 Supplement + Latin Extended-A, enough for accented Central European place names; other scripts won't render offline). Verified against the actual offline.pmtiles vector layer schema that the name/name:en/script fields this expects are present. Also nudge a handful of OFFLINE_THEME color roles (background, water, wood, buildings, the two road-importance tiers) towards the online style's actual palette (sampled from its style JSON) so switching Online/Offline doesn't look like two different apps — deliberately partial, not the removed full recolor.
This commit is contained in:
1 parent
06ea8ea141
commit
0887ccbfe7
12 files changed
+163
-217
No files matched your search
+27
-47
@@ -70,59 +70,39 @@ support) just returns byte ranges of the file; pmtiles.js in the
|
||||
browser reads the archive's own directory and requests only the bytes
|
||||
it needs for the tiles on screen.
|
||||
|
||||
=== Known limitation: no offline text labels
|
||||
=== Offline text labels and color palette
|
||||
|
||||
The offline style only renders `protomaps-themes-base`'s non-label
|
||||
layers (roads, buildings, land use, water — no place names or street
|
||||
labels). Label rendering in MapLibre needs a "glyphs" server serving
|
||||
font PBF ranges, which would mean vendoring a font glyph set locally
|
||||
too; that has not been done, to keep the initial scope manageable.
|
||||
Revisit this if labelled offline maps turn out to matter in practice.
|
||||
Label rendering in MapLibre needs a "glyphs" server serving font PBF
|
||||
ranges (256 Unicode code points each); `data/offline.pmtiles`'s fields
|
||||
(`name`, `name:en`, `script`, ...) match what
|
||||
`protomaps-themes-base`'s `layers(source, theme, { lang: "en" })`
|
||||
expects for its label layers (verified against the actual PMTiles
|
||||
vector layer schema), so passing that option turns labels on. The
|
||||
glyphs themselves are vendored under `public/vendor/fonts/` — Noto
|
||||
Sans Regular/Italic/Medium, ranges `0-255` and `256-511`
|
||||
(Basic Latin + Latin-1 Supplement + Latin Extended-A, SIL OFL
|
||||
licensed, from
|
||||
https://github.com/protomaps/basemaps-assets[protomaps/basemaps-assets]),
|
||||
covering accented Latin place names (Slovak, Czech, Polish, German,
|
||||
...). Labels in other scripts (Cyrillic, Greek, CJK, ...) won't render
|
||||
offline, since those glyph ranges aren't vendored.
|
||||
|
||||
`public/js/map.js`'s `OFFLINE_THEME` also nudges a handful of color
|
||||
roles (background, water, wood, buildings, the two road-importance
|
||||
tiers) from `protomaps-themes-base`'s stock "light" theme towards the
|
||||
online "liberty" style's actual palette (sampled from its style JSON),
|
||||
so Online/Offline don't look like two different apps. This is
|
||||
deliberately partial — most roles (labels, casings, minor terrain
|
||||
fills, ...) are left at their theme defaults — not the kind of
|
||||
full per-layer recolor a previous iteration of this app did (and
|
||||
removed, along with any dependency on OsmAnd's own tile server, which
|
||||
this app cannot use per OsmAnd's terms restricting tile use to "personal,
|
||||
non-commercial use within OsmAnd applications and platforms").
|
||||
|
||||
No PMTiles file ships with the repository — it is expected to be
|
||||
supplied locally (see `docs/development.adoc`) and stays gitignored
|
||||
because such extracts are typically large binary files.
|
||||
|
||||
=== Visual style
|
||||
|
||||
Both styles are recolored, by `public/js/osmand-style.js`, to
|
||||
approximate the look of https://osmand.net/map[OsmAnd's own web map]
|
||||
(cream background, green forests, orange roads, purple admin
|
||||
boundaries) — deliberately *not* by using OsmAnd's tile server
|
||||
directly: its terms restrict tile use to "personal, non-commercial use
|
||||
within OsmAnd applications and platforms", which this app isn't.
|
||||
|
||||
One shared color palette drives two independent recolorings:
|
||||
|
||||
* *Online*: `onlineStyle()` fetches OpenFreeMap's raw "liberty" style
|
||||
JSON and patches `paint` colors on its layers in place — matching a
|
||||
layer to a category (water, wood, park, landuse, building, major/
|
||||
minor road, boundary) by its id, then walking that layer's color
|
||||
properties (`background-color`, `fill-color`, `line-color`,
|
||||
`fill-extrusion-color`, and any `*-outline-color`) and replacing
|
||||
every color-shaped leaf — including inside `interpolate`/other
|
||||
expressions — with the category's palette color, leaving non-color
|
||||
leaves (operators, zoom stops, `["get", ...]`) untouched. Labels and
|
||||
railways are left at their original colors — only categorized layer
|
||||
types (`background`/`fill`/`line`/`fill-extrusion`) are touched at
|
||||
all, so `symbol` layers (all labels/icons) are never in scope.
|
||||
Result is cached after the first fetch.
|
||||
* *Offline*: `offlineTheme()` overrides the relevant color roles on a
|
||||
`protomaps-themes-base` `Theme` object (starting from
|
||||
`namedTheme("light")`), leaving roles it doesn't set (labels — moot,
|
||||
see above — rail, tunnels, POI colors) at their defaults.
|
||||
|
||||
=== Known limitation: coarser road colors offline
|
||||
|
||||
protomaps-themes-base's `Theme` only has two paint-relevant road tiers
|
||||
(`major` / `minor_a`+`minor_b`, plus `link` for ramps) versus
|
||||
OpenFreeMap's finer-grained classes (`road_motorway`,
|
||||
`road_trunk_primary`, `road_secondary_tertiary`, `road_minor`, ...).
|
||||
Mapping `major` to the palette's road-major orange colors more roads
|
||||
orange offline than online (protomaps' "major" bucket is broader than
|
||||
just motorway/trunk/primary) — a real difference in how coarse the two
|
||||
underlying style systems are, not a bug in the recoloring itself.
|
||||
|
||||
== Weather radar overlay
|
||||
|
||||
`public/js/radar.js` adds a "Radar" map control that overlays recent
|
||||
|
||||
Reference in new issue
Block a user