Repository navigation
Per-Trip China Map Mode (Amap / GCJ-02) #1636
Replies: 3 comments
|
Merging in #1673 (AMap as place search provider). Additional scope from that thread worth folding in: normalize AMap |
|
Running the 1. Amap as a fallback never gets reached in China
Measured on my instance, same query, same bias (Suzhou):
Query was Suggestion: an explicit choice should answer first; Two things that need to come with it, both found the hard way:
I have this implemented against 2.
|
| source | result |
|---|---|
Amap webrd01.is.autonavi.com |
36 ms |
| OpenStreetMap DE mirror | 0.7–1.3 s |
| OpenFreeMap | 2.6–3.2 s |
| tile.openstreetmap.org, CARTO, Stadia, Google | all time out |
GCJ-02 offset, measured against the transform: Suzhou 465 m, Shanghai Bund 479 m, Beijing Forbidden City 556 m — so the gcj02Crs approach in dev is doing real work; the numbers are well past "close enough".
One gotcha worth a line in the docs: isGcj02Basemap() matches on the host (*.is.autonavi.com). A self-hosted tile proxy that pre-corrects the offset and serves it from its own domain is therefore correctly left alone by the CRS — but anyone proxying Amap unchanged under their own hostname will silently lose the correction.
Also, at low zoom Amap answers with 1-bit palette PNGs (z=11 here, 179-byte single-colour tiles). Anything that decodes those tiles server-side needs to handle bit depths below 8; the browser doesn't care, but a proxy does.
|
Thanks @davidpopovici01 and @LYJW131! Coming in the next big release: with Amap picked as the place search provider, searches and suggestions centred inside China now ask Amap first, and everywhere else the usual order stays, so nothing lands in Macau by accident. |
Uh oh!
There was an error while loading. Please reload this page.
Problem
Planning trips in mainland China results in ~500m coordinate offset because Trek uses WGS-84 while Chinese maps use GCJ-02. This makes pins, search results, and routes visually incorrect.
Proposed Solution
Add a
use_chinese_mapboolean flag to trips. When enabled:Public dev key exists for testing purposes, but it has limited daily quota.
Why No Coordinate Conversion
GCJ-02 reverse engineering is legally gray in China. This approach avoids transformations like
eviltransformentirely by keeping everything in GCJ-02 for Chinese trips.Amap APIs Used (Free Tier)
v3/place/text— searchv3/place/detail— place detailsv3/direction/driving— routing (150K/month, essentially unlimited)v3/assistant/inputtips— excluded (shares 5K/month quota with search, too tight)Key Storage
Follows existing
llm_api_key/UNSPLASH_ACCESS_KEYpattern: encrypted in settings table, env override supported, never sent to browser.Known Limitations
Implementation Scope
~35 files, mostly additive. No architectural changes to global map settings.
Questions for Maintainers
amap:POI ID prefix acceptable for routing around theplaceId.includes(':')→ OSM heuristic?All reactions