feat(maps): show where an Amap hit came from, and keep its id

An Amap row now carries the same source mark the TREK index, OpenStreetMap
and Google rows get, named per locale because 高德地图 is the name it goes
by where it matters. The "search is on OpenStreetMap" notices and the
key hint in the details column are gone with the keys dev had already
removed, and the client-side provider mirror with them.

amap_poi_id travels with a picked result into the form, the details
column and the shadow log, so a saved place keeps the id it was found
by. A pasted Amap link goes to the resolver like a Google one.
This commit is contained in:
Maurice
2026-09-12 13:56:48 +02:00
parent 43a6c30325
commit 84c277993c
35 changed files with 148 additions and 459 deletions
+18 -7
View File
@@ -11,10 +11,11 @@
* nothing on the other is worse than either alone.
*/
import type { TranslationFn } from '../types'
/**
* The three names are proper nouns, so they are not translated, and that is
* also why there is no fourth: a source without a name people already know
* would need a string in 23 languages to say less than nothing.
* Proper nouns, so they are not translated. A source without a name people
* already know would need a string in 23 languages to say less than nothing.
*/
export const SOURCE_LABELS: Record<string, string> = {
'trek-places': 'TREK',
@@ -23,6 +24,14 @@ export const SOURCE_LABELS: Record<string, string> = {
google: 'Google',
}
/**
* The one name that changes with the reader: 高德地图 to the people it exists
* for, Amap to everyone else. Hence a locale string rather than a fourth noun.
*/
const SOURCE_KEYS: Record<string, string> = {
amap: 'places.source.amap',
}
/**
* The label for one row.
*
@@ -31,9 +40,11 @@ export const SOURCE_LABELS: Record<string, string> = {
* answered the call: Google never marks its places, and a merged list marks only
* the index side, so an unmarked row in one is OpenStreetMap by elimination.
*/
export function sourceLabelFor(place: unknown, listSource: string): string | null {
export function sourceLabelFor(place: unknown, listSource: string, t: TranslationFn): string | null {
const own = (place as { source?: unknown } | null)?.source
if (typeof own === 'string' && own) return SOURCE_LABELS[own] ?? null
if (listSource.includes('openstreetmap')) return SOURCE_LABELS.openstreetmap
return SOURCE_LABELS[listSource] ?? null
const source = typeof own === 'string' && own
? own
: listSource.includes('openstreetmap') ? 'openstreetmap' : listSource
if (SOURCE_KEYS[source]) return t(SOURCE_KEYS[source])
return SOURCE_LABELS[source] ?? null
}