Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 1 addition & 33 deletions src/components/DeckGLMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import { HeatmapLayer } from '@deck.gl/aggregation-layers';
import type { WeatherAlert } from '@/services/weather';
import { escapeHtml } from '@/utils/sanitize';
import { tokenizeForMatch, matchKeyword, matchesAnyKeyword, findMatchingKeywords } from '@/utils/keyword-match';
import { t, getCurrentLanguage } from '@/services/i18n';
import { t } from '@/services/i18n';
import { debounce, rafSchedule, getCurrentTheme } from '@/utils/index';
import {
INTEL_HOTSPOTS,
Expand Down Expand Up @@ -424,7 +424,6 @@ export class DeckGLMap {
this.rebuildTechHQSupercluster();
this.rebuildDatacenterSupercluster();
this.initDeck();
this.applyBasemapLocalization();
this.loadCountryBoundaries();
this.fetchServerBases();
this.render();
Expand Down Expand Up @@ -4718,7 +4717,6 @@ export class DeckGLMap {
// setStyle() replaces all sources/layers — reset guard so country layers are re-added
this.countryGeoJsonLoaded = false;
this.maplibreMap.once('style.load', () => {
this.applyBasemapLocalization();
this.loadCountryBoundaries();
this.updateCountryLayerPaint(theme);
// Re-render deck.gl overlay after style swap — interleaved layers need
Expand All @@ -4727,36 +4725,6 @@ export class DeckGLMap {
});
}

private applyBasemapLocalization(): void {
if (!this.maplibreMap) return;
const style = this.maplibreMap.getStyle();
const layers = style?.layers ?? [];
const lang = getCurrentLanguage();
const localizedNameField = lang === 'en' ? 'name_en' : `name_${lang}`;

for (const layer of layers) {
const layerType = (layer as { type?: string }).type;
if (layerType !== 'symbol') continue;

const sourceLayer = (layer as { 'source-layer'?: string })['source-layer'];
if (sourceLayer !== 'place') continue;

const layout = (layer as { layout?: Record<string, unknown> }).layout;
if (!layout || layout['text-field'] == null) continue;

try {
this.maplibreMap.setLayoutProperty(layer.id, 'text-field', [
'coalesce',
['get', localizedNameField],
['get', 'name'],
['get', 'name_en'],
]);
} catch {
// Some style layers may reject runtime text-field updates; skip those safely.
}
}
}

private updateCountryLayerPaint(theme: 'dark' | 'light'): void {
if (!this.maplibreMap || !this.countryGeoJsonLoaded) return;
const hoverOpacity = theme === 'light' ? 0.10 : 0.06;
Expand Down