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.
This commit is contained in:
parent
392ce11e20
commit
fc05faa90e
2 changed files with 10 additions and 2 deletions
|
|
@ -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) : []))
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue