diff --git a/plugin-designs/upg-neighbor/src/campaigns.vue b/plugin-designs/upg-neighbor/src/campaigns.vue index cf76549b3..0d8f3f139 100644 --- a/plugin-designs/upg-neighbor/src/campaigns.vue +++ b/plugin-designs/upg-neighbor/src/campaigns.vue @@ -84,9 +84,13 @@ const SRC_R = 'cp-r', SRC_U = 'cp-u' const fc = (features) => ({ type: 'FeatureCollection', features }) const pt = (g) => ({ type: 'Feature', geometry: { type: 'Point', coordinates: [g.lng, g.lat] }, properties: { id: g.pgid, pop: g.pop, b: g.believers } }) function setSrc(m, id, d) { const s = m.getSource(id); if (s) s.setData(d); else m.addSource(id, { type: 'geojson', data: d }) } +let repaintPending = false function repaint() { const m = map.value - if (!m || !m.isStyleLoaded?.()) return + if (!m) return + // isStyleLoaded() is also false while TILES load (MapLibre), so a data load that lands then used to + // be dropped for good: the start view showed no dots at all (rega, upgn6). Try again once idle. + if (!m.isStyleLoaded?.()) { if (!repaintPending) { repaintPending = true; m.once('idle', () => { repaintPending = false; repaint() }) } return } const b = active.value setSrc(m, SRC_U, fc(b ? b.unreached.map(pt) : [])) setSrc(m, SRC_R, fc(b ? b.reached.map(pt) : [])) diff --git a/plugin-designs/upg-neighbor/src/mobilize.vue b/plugin-designs/upg-neighbor/src/mobilize.vue index 680f16017..d880850b6 100644 --- a/plugin-designs/upg-neighbor/src/mobilize.vue +++ b/plugin-designs/upg-neighbor/src/mobilize.vue @@ -146,9 +146,13 @@ function ensureLayers(m) { function applyDim(m) { if (m.getLayer('nb-u')) m.setPaintProperty('nb-u', 'circle-opacity', selected.value ? 0.18 : 0.55) } +let repaintPending = false function repaint() { const m = map.value - if (!m || !m.isStyleLoaded?.()) return + if (!m) return + // isStyleLoaded() is also false while TILES load (MapLibre), so a data load that lands then used to + // be dropped for good: the start view showed no dots at all (rega, upgn6). Try again once idle. + if (!m.isStyleLoaded?.()) { if (!repaintPending) { repaintPending = true; m.once('idle', () => { repaintPending = false; repaint() }) } return } ensureLayers(m) } function frame() {