Skip to content

fix(worker): normalize map coordinates to WGS84 - #67

Open
SajoLuo wants to merge 1 commit into
Yu9191:mainfrom
SajoLuo:agent/fix-map-coordinate-systems
Open

fix(worker): normalize map coordinates to WGS84#67
SajoLuo wants to merge 1 commit into
Yu9191:mainfrom
SajoLuo:agent/fix-map-coordinate-systems

Conversation

@SajoLuo

@SajoLuo SajoLuo commented Jul 22, 2026

Copy link
Copy Markdown

What changed

  • Keep the Worker UI's internal coordinates in WGS84.
  • Convert Amap layer clicks, drags, marker positions, and map centers between GCJ-02 and WGS84.
  • Normalize direct Apple Maps and Amap coordinates before saving them to the device.
  • Move the existing Worker conversion functions into a shared coordinate module and add browser/runtime regression tests.

Why

The server-side parser already converted mainland Apple Maps and Amap coordinates to WGS84, but the web page treated every map layer and pasted coordinate as WGS84. Amap tiles use GCJ-02, so selecting a point on that layer or pasting a mainland Apple/Amap URL saved an offset coordinate. Switching between Amap and WGS84 layers could also move the visible center and marker.

Impact

  • Mainland map selections and pasted Apple/Amap coordinates no longer drift after being written to WLOC.
  • Switching layers keeps the same physical map location.
  • WGS84 layers, raw WGS84 coordinates, and coordinates outside mainland China keep their existing behavior.

Validation

  • cd worker && node --test (5 tests)
  • npx wrangler deploy --dry-run --minify
  • Loaded the minified Worker bundle, compiled its generated inline page script, and verified a public Apple Maps sample resolves to the expected WGS84 coordinate.
  • Confirmed the coordinate correction on-device.

@SajoLuo
SajoLuo marked this pull request as ready for review July 22, 2026 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant