Atlaslog / Field Notes / Coordinates & projections
Field note · Coordinates & projections
Changing CRS to EPSG:4326 squashes the map vertically
Quick answer
L.CRS.EPSG4326 gives one degree of longitude and one degree of latitude the same pixel length, but a degree of longitude shrinks by cos(lat). China is therefore flattened, circles become ellipses, and the distortion grows with latitude.
Symptom
- After setting crs: L.CRS.EPSG4326, a 1 km circular buffer measures about 1.30 wide-to-high on screen.
- A 10 km north-south road near Beijing at 39.9 N is only 76.7% as long on screen as under EPSG:3857.
- Provincial boundaries look horizontally stretched and the country outline appears flattened.
Checklist
- Draw a known 1 km x 1 km square and measure its on-screen width and height.
- Print map.options.crs.code to confirm whether the map is on EPSG:4326 or EPSG:3857.
- In a moveend handler compare map.getSize() with map.getBounds() and compute pixels-per-degree in both directions.
- Switch back to the default CRS and measure again; a restored shape confirms the projection choice is the cause.
Fix
Keep the default EPSG:3857 for display; use EPSG:4326 only for equal-angle gridded data such as weather rasters, and never for vector data that must keep its shape.
Code
map.on('moveend', () => {
const b = map.getBounds(), s = map.getSize();
const pxPerLon = s.x / (b.getEast() - b.getWest());
const pxPerLat = s.y / (b.getNorth() - b.getSouth());
console.log('px/度 经:', pxPerLon.toFixed(3), '纬:', pxPerLat.toFixed(3));
});const map = L.map('map', { center: [39.909, 116.397], zoom: 10 });
const map4326 = L.map('map2', {
crs: L.CRS.EPSG4326,
center: [39.909, 116.397],
zoom: 5
});
L.tileLayer('https://example.com/4326/{z}/{y}/{x}.png', {
tileSize: 256,
noWrap: true,
bounds: [[-90, -180], [90, 180]]
}).addTo(map4326);
Watch out
- Changing the CRS to 'get degrees straight out of the API'; Leaflet still works in projected pixels internally.
- Building 4326 tile layers without adjusting tileSize and bounds, which yields misaligned or half-empty tiles.
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). Changing CRS to EPSG:4326 squashes the map vertically. https://www.jingweizhi.com/en/cookbook/leaflet-4326-stretch.html (accessed 2026-11-03).