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
@@ -1,5 +1,5 @@
import { describe, it, expect } from 'vitest'
import { isGoogleMapsUrl } from './PlaceFormModal.helpers'
import { isAmapUrl, isGoogleMapsUrl, isMapUrl } from './PlaceFormModal.helpers'
describe('isGoogleMapsUrl', () => {
it('accepts the short share hosts', () => {
@@ -39,3 +39,25 @@ describe('isGoogleMapsUrl', () => {
expect(isGoogleMapsUrl(' https://maps.app.goo.gl/abc123 ')).toBe(true)
})
})
describe('isAmapUrl', () => {
it('accepts the share, web and short-link hosts', () => {
expect(isAmapUrl('https://uri.amap.com/marker?position=116.397,39.908&name=天安门')).toBe(true)
expect(isAmapUrl('https://www.amap.com/place/B000A7BD6C')).toBe(true)
expect(isAmapUrl('https://surl.amap.com/abc')).toBe(true)
})
it('is an exact host list, so a lookalike stays a search query', () => {
expect(isAmapUrl('https://amap.com.evil.example/place/x')).toBe(false)
expect(isAmapUrl('https://restapi.amap.com/v3/place/text')).toBe(false)
expect(isAmapUrl('天安门')).toBe(false)
})
})
describe('isMapUrl', () => {
it('sends either provider\'s link to the resolver and nothing else', () => {
expect(isMapUrl('https://maps.app.goo.gl/abc123')).toBe(true)
expect(isMapUrl('https://uri.amap.com/marker?position=116.397,39.908')).toBe(true)
expect(isMapUrl('https://example.com/maps')).toBe(false)
})
})