Atlaslog
Atlaslog / Field Notes / Styling & rendering
Field note · Styling & rendering

Long place names are truncated by a small text-max-width

Quick answer

A district label shows only its first six characters with no ellipsis and no wrapping. `text-max-width: 4` is measured in ems, so only about four Han characters fit per line and anything beyond the computed lines is cut off.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: Mapbox GL JS 2.15 / 3.x / MapLibre 4.x
Symptom
Checklist
  1. Read `layout['text-max-width']` and `text-size` for the layer
  2. Estimate characters per line: max-width in em roughly equals Han characters per line
  3. Temporarily set `text-max-width` to 20 and see whether the full name appears
  4. Check for a custom clip post-process or `overflow: hidden` on the container
  5. Measure the label texture height against the allowed number of lines
Fix

Raise `text-max-width` to 8 to 12 for Chinese, interpolate `text-size` by zoom (`['interpolate', ['linear'], ['zoom'], 8, 11, 14, 13, 17, 15]`), set `text-line-height: 1.2`, and insert a line break at a semantic boundary for names longer than about 8 characters.

Code
console.log(map.getLayer('district-label').layout['text-max-width']);   // 4
console.log(map.getLayer('district-label').layout['text-size']);        // 12
// 若同时 text-max-width 4 + text-size 12,字号 12px,可行宽度约 48px
map.addLayer({
  id: 'district-label',
  type: 'symbol',
  source: 'districts',
  layout: {
    'text-field': ['get', 'name'],
    'text-size': ['interpolate', ['linear'], ['zoom'], 8, 11, 14, 13, 17, 15],
    'text-max-width': 10,          // 中文每行约 10 字
    'text-line-height': 1.2,
    'text-max-angle': 30,
    'symbol-placement': 'point'
  },
  paint: {
    'text-color': '#1b2733',
    'text-halo-color': '#ffffff',
    'text-halo-width': 1.2
  }
});
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). Long place names are truncated by a small text-max-width. https://www.jingweizhi.com/en/cookbook/label-text-clipped.html (accessed 2026-11-03).