Atlaslog
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.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: Leaflet · OpenLayers · Cesium
Symptom
Checklist
  1. Hide the basemap and check the data alone.
  2. Hide the data and check the basemap alone.
  3. If both look right, compare the declared CRS of the two sources; a uniform few-hundred-metre shift means a datum mismatch.
  4. If the offset is about twice the normal value, look for a second wgs84ToGcj02 call in the pipeline.
  5. 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
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

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).