Browse Source
补交 MonitorView 依赖的 mapLabels 模块;客户端 deadline 到达时递增 commandProgressEpoch,避免迟到响应清掉超时文案。main
2 changed files with 34 additions and 0 deletions
@ -0,0 +1,33 @@ |
|||||
|
/** |
||||
|
* Prefer Simplified Chinese labels on Mapbox basemap symbol layers. |
||||
|
* Falls back to name_zh / name when localized fields are absent. |
||||
|
*/ |
||||
|
export function applyChineseLabels(map) { |
||||
|
if (!map?.getStyle) return |
||||
|
let layers = [] |
||||
|
try { |
||||
|
layers = map.getStyle()?.layers || [] |
||||
|
} catch (_) { |
||||
|
return |
||||
|
} |
||||
|
|
||||
|
const textField = [ |
||||
|
'coalesce', |
||||
|
['get', 'name_zh-Hans'], |
||||
|
['get', 'name_zh'], |
||||
|
['get', 'name'], |
||||
|
] |
||||
|
|
||||
|
for (const layer of layers) { |
||||
|
if (layer?.type !== 'symbol') continue |
||||
|
if (!layer.layout?.['text-field']) continue |
||||
|
// Keep app-owned overlays (device/route labels) on their own text-field
|
||||
|
const id = String(layer.id || '') |
||||
|
if (id.startsWith('laic-') || id.startsWith('monitor-') || id.startsWith('route-')) continue |
||||
|
try { |
||||
|
map.setLayoutProperty(layer.id, 'text-field', textField) |
||||
|
} catch (_) { |
||||
|
/* layer may not support text-field mutation */ |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue