Atlaslog / Field Notes / Tiles
Field note · Tiles
One-pixel white seams between tiles
Quick answer
Every tile loads, yet the mosaic shows thin white lines that get denser at lower zoom. Fractional pixel positioning from a container size that is not a multiple of `tileSize`, together with browser scaling and antialiasing, produces the gaps.
Symptom
- One CSS-pixel pale seams appear at 2560x1440, most visible on dark imagery and nearly a mesh at zoom 10
- `layer.getContainer().style.transform` reads `translate3d(1023.5px, 767.5px, 0px)`
- `map.getSize()` returns `Point(1023, 767)`, not a multiple of 256
- Seams disappear at browser zoom 100% and return at 110% or 125%
Checklist
- Set browser zoom to 100% and see whether the seams vanish
- Log the tile container transform and look for fractional values
- Check the map container width and height against a multiple of `tileSize`
- Look for a CSS `scale` or `zoom` on an ancestor of the map
- Compare `tileSize` with the actual tile pixel dimensions
Fix
Oversize tiles by one pixel (`.leaflet-tile { width: 257px !important; height: 257px !important; }`), avoid fractional transforms by snapping the container to a multiple of 256, and for 512-pixel tiles set `tileSize: 512` with `zoomOffset: -1` and `detectRetina: false`.
Code
console.log(layer.getContainer().style.transform);
console.log(map.getSize()); // Point(1023, 767) 不是 256 的整数倍/* 1. 让瓦片比格子大 1 像素,缝隙被覆盖 */
.leaflet-tile {
width: 257px !important;
height: 257px !important;
}
/* 2. 关闭瓦片层的硬件加速,避免小数像素抗锯齿 */
.leaflet-tile-container {
will-change: auto;
transform-style: flat;
}
Watch out
- Applying `image-rendering: pixelated`, which sharpens the seam into a hard edge and blurs labels
- Setting `tileSize: 512` while keeping `zoomOffset: 0`, which doubles both the gaps and the offset
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Atlaslog (2026). One-pixel white seams between tiles. https://www.jingweizhi.com/en/cookbook/tile-seam-gap.html (accessed 2026-11-03).