mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-06-10 08:54:38 +02:00
fix: apply theme overlay config to contour layers
addContours() was using hardcoded black/white colors instead of theme-specific overlay config. Now uses getOverlayConfig(themeId, "contours") like other overlay layers (hillshade, publicLands, etc). Also updates cyberpunk contours from dark purple to cyan (#1a5566 → #3a99aa) to contrast with purple roads. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
d4e3b68a13
commit
fcc9101239
2 changed files with 447 additions and 430 deletions
|
|
@ -560,9 +560,11 @@ function removePublicLands(map) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add topographic contours via maplibre-contour */
|
/** Add topographic contours via maplibre-contour */
|
||||||
function addContours(map) {
|
function addContours(map, themeId) {
|
||||||
console.log('[CONTOUR] addContours called, source exists:', !!map?.getSource(CONTOUR_SOURCE), 'demSource:', !!demSourceInstance)
|
console.log("[CONTOUR] addContours called, source exists:", !!map?.getSource(CONTOUR_SOURCE), "demSource:", !!demSourceInstance)
|
||||||
if (!map || !demSourceInstance || map.getSource(CONTOUR_SOURCE)) return
|
if (!map || !demSourceInstance || map.getSource(CONTOUR_SOURCE)) return
|
||||||
|
|
||||||
|
const c = getOverlayConfig(themeId, "contours")
|
||||||
const contourThresholds = {
|
const contourThresholds = {
|
||||||
3: [5000, 25000],
|
3: [5000, 25000],
|
||||||
4: [2500, 10000],
|
4: [2500, 10000],
|
||||||
|
|
@ -579,54 +581,69 @@ function addContours(map) {
|
||||||
15: [20, 100],
|
15: [20, 100],
|
||||||
}
|
}
|
||||||
map.addSource(CONTOUR_SOURCE, {
|
map.addSource(CONTOUR_SOURCE, {
|
||||||
type: 'vector',
|
type: "vector",
|
||||||
tiles: [demSourceInstance.contourProtocolUrl({
|
tiles: [demSourceInstance.contourProtocolUrl({
|
||||||
multiplier: 3.28084,
|
multiplier: 3.28084,
|
||||||
thresholds: contourThresholds,
|
thresholds: contourThresholds,
|
||||||
})],
|
})],
|
||||||
maxzoom: 16,
|
maxzoom: 16,
|
||||||
})
|
})
|
||||||
console.log('[CONTOUR] protocol URL:', demSourceInstance.contourProtocolUrl({
|
console.log("[CONTOUR] protocol URL:", demSourceInstance.contourProtocolUrl({
|
||||||
multiplier: 3.28084,
|
multiplier: 3.28084,
|
||||||
thresholds: contourThresholds,
|
thresholds: contourThresholds,
|
||||||
}))
|
}))
|
||||||
console.log('[CONTOUR] source added:', !!map.getSource(CONTOUR_SOURCE))
|
console.log("[CONTOUR] source added:", !!map.getSource(CONTOUR_SOURCE))
|
||||||
let beforeId = undefined
|
let beforeId = undefined
|
||||||
for (const layer of map.getStyle().layers) {
|
for (const layer of map.getStyle().layers) {
|
||||||
if (layer.type === 'symbol') { beforeId = layer.id; break }
|
if (layer.type === "symbol") { beforeId = layer.id; break }
|
||||||
}
|
}
|
||||||
const isDark = document.documentElement.getAttribute('data-theme') === 'dark'
|
|
||||||
|
// Line layer with theme-aware colors
|
||||||
|
// maplibre-contour level: 0 = minor, 1 = index (major)
|
||||||
|
const opacityMod = c.opacityMod ?? 1
|
||||||
map.addLayer({
|
map.addLayer({
|
||||||
id: CONTOUR_LINE, type: 'line', source: CONTOUR_SOURCE,
|
id: CONTOUR_LINE, type: "line", source: CONTOUR_SOURCE,
|
||||||
'source-layer': 'contours',
|
"source-layer": "contours",
|
||||||
paint: {
|
paint: {
|
||||||
'line-color': 'rgba(0,0,0,0.35)',
|
"line-color": [
|
||||||
'line-width': [
|
"match", ["get", "level"],
|
||||||
'interpolate', ['linear'], ['zoom'],
|
1, c.indexColor,
|
||||||
7, ['match', ['get', 'level'], 1, 1, 0.3],
|
c.minorColor
|
||||||
11, ['match', ['get', 'level'], 1, 1.5, 0.6],
|
],
|
||||||
14, ['match', ['get', 'level'], 1, 2, 0.8],
|
"line-opacity": [
|
||||||
|
"match", ["get", "level"],
|
||||||
|
1, c.indexOpacity * opacityMod,
|
||||||
|
c.minorOpacity * opacityMod
|
||||||
|
],
|
||||||
|
"line-width": [
|
||||||
|
"interpolate", ["linear"], ["zoom"],
|
||||||
|
7, ["match", ["get", "level"], 1, c.indexWidth?.z4 ?? 1.2, c.minorWidth?.z11 ?? 0.5],
|
||||||
|
11, ["match", ["get", "level"], 1, ((c.indexWidth?.z4 ?? 1.2) + (c.indexWidth?.z14 ?? 1.8)) / 2, ((c.minorWidth?.z11 ?? 0.5) + (c.minorWidth?.z14 ?? 1.0)) / 2],
|
||||||
|
14, ["match", ["get", "level"], 1, c.indexWidth?.z14 ?? 1.8, c.minorWidth?.z14 ?? 1.0],
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}, beforeId)
|
}, beforeId)
|
||||||
|
|
||||||
|
// Label layer for index contours (level > 0)
|
||||||
map.addLayer({
|
map.addLayer({
|
||||||
id: CONTOUR_LABEL, type: 'symbol', source: CONTOUR_SOURCE,
|
id: CONTOUR_LABEL, type: "symbol", source: CONTOUR_SOURCE,
|
||||||
'source-layer': 'contours',
|
"source-layer": "contours",
|
||||||
filter: ['>', ['get', 'level'], 0],
|
filter: [">", ["get", "level"], 0],
|
||||||
layout: {
|
layout: {
|
||||||
'symbol-placement': 'line',
|
"symbol-placement": "line",
|
||||||
'text-size': ['interpolate', ['linear'], ['zoom'], 7, 9, 11, 11, 14, 13],
|
"text-size": c.labelSize ?? 10,
|
||||||
'text-field': ['concat', ['number-format', ['get', 'ele'], {}], "'"],
|
"text-field": ["concat", ["number-format", ["get", "ele"], {}], "'"],
|
||||||
'text-font': ['Noto Sans Medium'],
|
"text-font": c.labelFont ?? ["Noto Sans Regular"],
|
||||||
'text-max-angle': 25,
|
"text-max-angle": 25,
|
||||||
},
|
},
|
||||||
paint: {
|
paint: {
|
||||||
'text-color': 'rgba(0,0,0,0.7)',
|
"text-color": c.labelColor,
|
||||||
'text-halo-color': 'rgba(255,255,255,0.9)',
|
"text-halo-color": c.labelHaloColor,
|
||||||
'text-halo-width': 1.5,
|
"text-halo-width": c.labelHaloWidth ?? 1.5,
|
||||||
|
"text-opacity": (c.labelOpacity ?? 0.85) * opacityMod,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
console.log('[CONTOUR] layers added:', !!map.getLayer(CONTOUR_LINE), !!map.getLayer(CONTOUR_LABEL))
|
console.log("[CONTOUR] layers added:", !!map.getLayer(CONTOUR_LINE), !!map.getLayer(CONTOUR_LABEL))
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove contour layers + source */
|
/** Remove contour layers + source */
|
||||||
|
|
|
||||||
|
|
@ -230,22 +230,22 @@ const cyberpunkOverlay = {
|
||||||
|
|
||||||
// Contours - very subtle dark purple-gray
|
// Contours - very subtle dark purple-gray
|
||||||
contours: {
|
contours: {
|
||||||
opacityMod: 0.5,
|
opacityMod: 1.0,
|
||||||
minorColor: '#1e1e3e',
|
minorColor: "#1a5566",
|
||||||
minorOpacity: 0.3,
|
minorOpacity: 0.5,
|
||||||
minorWidth: { z11: 0.4, z14: 0.8 },
|
minorWidth: { z11: 0.5, z14: 1.0 },
|
||||||
intermediateColor: '#2a2a4a',
|
intermediateColor: "#2a7788",
|
||||||
intermediateOpacity: 0.4,
|
intermediateOpacity: 0.65,
|
||||||
intermediateWidth: { z8: 0.6, z14: 1.0 },
|
intermediateWidth: { z8: 0.8, z14: 1.2 },
|
||||||
indexColor: '#3a3a5a',
|
indexColor: "#3a99aa",
|
||||||
indexOpacity: 0.5,
|
indexOpacity: 0.8,
|
||||||
indexWidth: { z4: 0.8, z14: 1.2 },
|
indexWidth: { z4: 1.2, z14: 1.8 },
|
||||||
labelColor: '#5a5a7a',
|
labelColor: "#55ccdd",
|
||||||
labelHaloColor: '#0a0a14',
|
labelHaloColor: "#0a0a14",
|
||||||
labelHaloWidth: 1.5,
|
labelHaloWidth: 1.5,
|
||||||
labelOpacity: 0.6,
|
labelOpacity: 0.85,
|
||||||
labelSize: 10,
|
labelSize: 10,
|
||||||
labelFont: ['Noto Sans Regular'],
|
labelFont: ["Noto Sans Regular"],
|
||||||
},
|
},
|
||||||
|
|
||||||
// Contours Test - cyan variant
|
// Contours Test - cyan variant
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue