From fc05faa90e063e9c09cca4cbc382e50329d6c638 Mon Sep 17 00:00:00 2001 From: Doxa Maps Date: Sun, 27 Sep 2026 22:26:29 +0000 Subject: [PATCH] UPG Neighbor: the start view shows the unreached dots When the data arrived while the map was still loading tiles, the paint was skipped and never retried, so Mobilize opened on an empty map (and Campaigns could miss its dots the same way). A skipped paint now retries once the map is idle. --- plugin-designs/upg-neighbor/src/campaigns.vue | 6 +++++- plugin-designs/upg-neighbor/src/mobilize.vue | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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() {