#13717·mapbox-gl-js

drawFill 读取 layer.layout 而不进行保护: 从 styledata 监听器添加的图层在重新计算之前就被绘制

作者: guillem-aistech创建于 2026年8月20日更新于 2026年8月20日
标签bug :lady_beetle:auto-triaged
  1. Map._render()this.style.update(parameters)src/ui/map.ts:4537
  2. Style.update() recalculates layers — src/style/style.ts:1797
typescript
if (layer.visibility !== 'none' || layer.hasTransition()) layer.recalculate(parameters, this._availableImages);
  1. Style.update() then fires styledata at its tail — src/style/style.ts:1870
typescript
if (changed) {
    this.fire(new Event('data', {dataType: 'style'}));
}

A listener calling map.addLayer() here inserts a layer after step 2 has run. 4. Map._render()this.painter.render(this.style, …)src/ui/map.ts:4570 5. Painter.renderLayer guards only on isHidden() and coords.lengthsrc/render/painter.ts:1497-1499. It never checks layout. 6. drawFillsrc/render/draw_fill.ts:80

typescript
if (layer.layout.get('fill-elevation-reference') !== 'none') {  // throws

layout is assigned only in StyleLayer.recalculate() (src/style/style_layer.ts:315-322), so the freshly added layer has none.

内容来源: mapbox/mapbox-gl-js