Atlaslog / Field Notes / Services & tile access
Field note · Services & tile access
Switching to a domestic basemap: what actually has to change
Quick answer
Moving from OpenStreetMap to Tianditu, Amap or Tencent is not just a URL swap. The coordinate system, key, protocol and quota rules all change, and Amap and Tencent use GCJ-02, so business data must be converted before display.
Symptom
- Tiles stay entirely grey because the key is refused or not bound to the current domain.
- The basemap loads but points sit a few hundred metres off because the GCJ-02 conversion is missing.
- Only vec or img is added, so the imagery appears without any labels.
Checklist
- Confirm the provider's CRS: Tianditu is CGCS2000 and close to WGS84, while Amap and Tencent are GCJ-02.
- Paste the full tile URL into the address bar first; Tianditu is WMTS with TILEMATRIX, TILEROW and TILECOL rather than {z}/{x}/{y}.png.
- Check the key whitelist: working on localhost but 403 in production points at the bound domain.
- Check maxZoom against the service's real upper level.
- Check whether y must be flipped for a TMS source.
- Verify that the data pipeline converts WGS84 to GCJ-02 once, at display time.
Fix
Keep raw data in WGS84 and convert once before rendering on a GCJ-02 basemap with wgs84ToGcj02, and build the Tianditu URL with SERVICE=WMTS, REQUEST=GetTile, VERSION=1.0.0, LAYER=vec, STYLE=default, TILEMATRIXSET=w, FORMAT=tiles, TILEMATRIX={z}, TILEROW={y}, TILECOL={x} and tk, using subdomains 0 to 7.
Code
L.tileLayer(
'https://t{s}.tianditu.gov.cn/vec_w/wmts?SERVICE=WMTS&REQUEST=GetTile' +
'&VERSION=1.0.0&LAYER=vec&STYLE=default&TILEMATRIXSET=w' +
'&FORMAT=tiles&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=你的KEY',
{ subdomains: '01234567', maxZoom: 18 }
).addTo(map);L.tileLayer(
'https://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1' +
'&scale=1&style=8&x={x}&y={y}&z={z}',
{ subdomains: '1234', maxZoom: 18 }
).addTo(map);
Watch out
- Converting coordinates during import and storing GCJ-02, after which the data can never be used with Tianditu or in GIS analysis again.
- Hardcoding Amap style=8 tiles as a production dependency: there is no key check and no stability guarantee, so the official API is the right path.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). Switching to a domestic basemap: what actually has to change. https://www.jingweizhi.com/en/cookbook/domestic-basemap.html (accessed 2026-11-03).