An overlay's layers which the basemap already draws start hidden (#969)

A file of features often carries a basemap's layers too (roads, water, buildings, place names).
Drawn over the basemap they double every road and label.  Those layers, by the names of the
Protomaps and OpenMapTiles schemas, are now off until they are checked; every other layer is on
as before, and a choice already made is kept.

Co-authored-by: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
lrnselfreliance 2026-11-14 11:17:31 -07:00 • committed by GitHub
parent 38832870c9
commit 0389e4659c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 99 additions and 22 deletions

View file

@ -126,9 +126,28 @@ export function isOverlayEnabled(state, file) {
return state?.[file.map_path]?.enabled === true;
}
// Once a file is on, each of its layers is drawn until the user turns that layer off.
// The layers of the schemas a basemap is commonly made in (Protomaps, which the map's own basemap
// is, and OpenMapTiles). A file which also has other things often carries these too, and drawing
// them again over the basemap doubles every road and label.
const BASEMAP_LAYERS = new Set([
// Protomaps
"earth", "water", "roads", "landuse", "landcover", "buildings", "boundaries", "places", "pois",
"transit", "natural", "physical_line", "physical_point",
// OpenMapTiles
"waterway", "water_name", "landuse", "landcover", "park", "boundary", "aeroway", "aerodrome_label",
"transportation", "transportation_name", "building", "place", "poi", "mountain_peak",
]);
// Whether a layer of an overlay is of something the basemap already draws.
export function isBasemapLayer(layerId) {
return BASEMAP_LAYERS.has(String(layerId ?? "").toLowerCase());
}
// Once a file is on, each of its layers is as the user chose. A layer the user has not chosen for
// is drawn, unless the basemap already draws the same thing.
export function isOverlayLayerEnabled(state, file, layerId) {
return state?.[file.map_path]?.layers?.[layerId] !== false;
const chosen = state?.[file.map_path]?.layers?.[layerId];
return typeof chosen === "boolean" ? chosen : !isBasemapLayer(layerId);
}
export function setOverlayEnabled(state, file, enabled) {