Atlaslog / Field Notes / Coordinates & projections
Field note · Coordinates & projections
Basemap and data are each correct but misalign when overlaid
Quick answer
Data on a blank canvas sits on the right roads and the basemap alone looks normal, yet the overlay is uniformly shifted. The cause is a CRS mismatch between the two sources, a doubled conversion, or Baidu's non-standard tile numbering.
Symptom
- Data on an empty canvas sits exactly over the correct roads, but adding the Amap tile layer moves every feature a few hundred meters in one direction.
- The shift is constant within a city and roughly equals one WGS84 to GCJ-02 offset.
- In Cesium the vector layer floats above or sinks into the terrain because Cartesian3.fromDegrees expects WGS84 while the tiles are GCJ-02.
Checklist
- Hide the basemap and check the data alone.
- Hide the data and check the basemap alone.
- If both look right, compare the declared CRS of the two sources; a uniform few-hundred-metre shift means a datum mismatch.
- If the offset is about twice the normal value, look for a second wgs84ToGcj02 call in the pipeline.
- If the map is torn into mismatched tiles rather than uniformly shifted, suspect Baidu tile numbering rather than CRS.
Fix
Convert both sides to one CRS — normally GCJ-02 for Amap/Tencent/Baidu tiles, no conversion at all for Tianditu (CGCS2000) or OSM. For Baidu also switch to its own tile scheme instead of the standard {z}/{x}/{y} grid.
Code
var gcj = wgs84ToGcj02(lng, lat);
var gcj2 = wgs84ToGcj02(lng, lat); // 偏移变成两倍
var wrong = gcj02ToWgs84(lng, lat); // 方向相反,越修越偏
Watch out
- Converting WGS84 data to GCJ-02 while the basemap is already Tianditu CGCS2000, which introduces an offset that was not there.
- Feeding Baidu tiles into a standard Web Mercator tile layer and expecting a CRS fix alone to align them.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). Basemap and data are each correct but misalign when overlaid. https://www.jingweizhi.com/en/cookbook/basemap-misalign.html (accessed 2026-11-03).