Country posters: pre-warm skips only paints that already read the feature
An array is not the same as data-driven: a zoom-only interpolate is an array and still compiles a variant on the first gesture. The warm-up now leaves alone only values that read a feature property, and wraps constants and zoom-only expressions.
This commit is contained in:
parent
4b941be4bf
commit
97903f756a
1 changed files with 5 additions and 1 deletions
|
|
@ -1431,10 +1431,14 @@ async function ensureRegionsLoaded() {
|
|||
// compile (rega on research-map: 5.5 s MapLibre / 11.1 s Mapbox under SwiftShader). Painting each
|
||||
// current value through a case with two identical branches keeps the look and moves the compile
|
||||
// off the gesture. All three, or the other two still compile on the click (simpleresearch).
|
||||
// "Already data-driven" means the value READS THE FEATURE somewhere, not merely that it is an
|
||||
// array: a zoom-only interpolate is an array and still compiles a variant on the first gesture
|
||||
// (simpleresearch). Anything keyed on a feature is left exactly as the layer wrote it.
|
||||
const readsFeature = (e) => Array.isArray(e) && (e[0] === 'get' || e[0] === 'has' || e[0] === 'feature-state' || e.some(readsFeature))
|
||||
for (const [layer, prop] of [['regions-fill', 'fill-opacity'], ['regions-border', 'line-color'], ['regions-border', 'line-width']]) {
|
||||
try {
|
||||
const v = map.value.getLayer(layer) && map.value.getPaintProperty(layer, prop)
|
||||
if (v != null && !Array.isArray(v)) {
|
||||
if (v != null && !readsFeature(v)) {
|
||||
map.value.setPaintProperty(layer, prop, ['case', ['in', ['get', 'iso_3166_1_alpha_3'], ['literal', []]], v, v])
|
||||
}
|
||||
} catch (_) { /* a style without the layer: nothing to warm */ }
|
||||
|
|
|
|||
Loading…
Reference in a new issue