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

Labels pile up, and text-allow-overlap makes it worse

Quick answer

Only a few dozen of 823 POI labels appear because collision detection hides the rest; enabling `text-allow-overlap` shows all 823 on top of each other. That flag disables layout rather than solving crowding.

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. Compare `queryRenderedFeatures` and `querySourceFeatures` counts on the same layer
  2. Check `text-allow-overlap` and `text-ignore-placement` in the layout
  3. Check whether `symbol-placement: line` is forcing names into tight line layouts
  4. Check whether `text-size` grows linearly with zoom and inflates collision boxes
  5. Review `text-padding` and the layer's `minzoom`
Fix

Drive density with zoom filters and interpolated `text-size` instead of the overlap flag: keep `'text-allow-overlap': false`, set `'text-padding': 6`, and switch `setFilter('poi-label', ['>=', ['get', 'rank'], minRank])` on `zoomend` (rank 3 below z12, rank 1 from z14).

Code
const rendered = map.queryRenderedFeatures({ layers: ['poi-label'] }).length;
const total = map.querySourceFeatures('poi').length;
console.log(rendered, total);   // 68 823  -> 755 个被碰撞隐藏
map.addLayer({
  id: 'poi-label',
  type: 'symbol',
  source: 'poi',
  minzoom: 9,
  filter: ['>=', ['get', 'rank'], 1],        // rank 1 最重要
  layout: {
    'text-field': ['get', 'name'],
    'text-size': ['interpolate', ['linear'], ['zoom'], 9, 11, 14, 14, 18, 17],
    'text-padding': 6,
    'text-allow-overlap': false,
    'text-ignore-placement': false,
    'text-max-width': 8,
    'text-anchor': 'top',
    'text-offset': [0, 0.6]
  }
});
map.on('zoomend', () => {
  const z = map.getZoom();
  const minRank = z >= 14 ? 1 : z >= 12 ? 2 : 3;
  map.setFilter('poi-label', ['>=', ['get', 'rank'], minRank]);
});
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). Labels pile up, and text-allow-overlap makes it worse. https://www.jingweizhi.com/en/cookbook/label-overlap.html (accessed 2026-11-03).