fix(maps): localize map POI pin titles to the user's language

This commit is contained in:
Konstantinos Thermos
2026-07-24 11:00:03 +03:00
committed by Maurice
parent fce26618a1
commit e100c52676
8 changed files with 78 additions and 15 deletions
+2 -2
View File
@@ -885,8 +885,8 @@ export const mapsApi = {
// OSM-only POI explore: places of a category within the current map viewport bbox.
// Overpass can be slow on a fresh (uncached) area, so this call gets a longer
// timeout than the global default instead of aborting at 8s and showing nothing.
pois: (category: string, bbox: { south: number; west: number; north: number; east: number }, signal?: AbortSignal) =>
apiClient.get('/maps/pois', { params: { category, ...bbox }, signal, timeout: 20000 }).then(r => r.data as { pois: import('../components/Map/poiCategories').Poi[]; source: string; truncated: boolean; clamped?: boolean }),
pois: (category: string, bbox: { south: number; west: number; north: number; east: number }, lang?: string, signal?: AbortSignal) =>
apiClient.get('/maps/pois', { params: { category, ...bbox, lang }, signal, timeout: 20000 }).then(r => r.data as { pois: import('../components/Map/poiCategories').Poi[]; source: string; truncated: boolean; clamped?: boolean }),
}
export const airportsApi = {
+4 -2
View File
@@ -1,5 +1,6 @@
import { useState, useRef, useCallback, useMemo } from 'react'
import { mapsApi } from '../../api/client'
import { useTranslation } from '../../i18n'
import type { Poi } from './poiCategories'
export interface Bbox { south: number; west: number; north: number; east: number }
@@ -17,6 +18,7 @@ function isAbortError(err: unknown): boolean {
* Overpass load (and visual churn) down.
*/
export function usePoiExplore() {
const { locale } = useTranslation()
const [active, setActive] = useState<Set<string>>(() => new Set())
const [byCat, setByCat] = useState<Record<string, Poi[]>>({})
const [loadingKeys, setLoadingKeys] = useState<Set<string>>(() => new Set())
@@ -54,7 +56,7 @@ export function usePoiExplore() {
setLoading(key, true)
setError(key, false)
try {
const res = await mapsApi.pois(key, bbox, ctrl.signal)
const res = await mapsApi.pois(key, bbox, locale, ctrl.signal)
// Drop the result if the user toggled this category off while the (slow)
// Overpass request was in flight — otherwise stale results re-appear.
setByCat(prev => (activeRef.current.has(key) ? { ...prev, [key]: res.pois } : prev))
@@ -74,7 +76,7 @@ export function usePoiExplore() {
delete abortRef.current[key]
}
}
}, [setLoading, setError])
}, [setLoading, setError, locale])
const onViewportChange = useCallback((bbox: Bbox) => {
bboxRef.current = bbox