diff --git a/src/layers/streetLevel/providers/kartaview/index.js b/src/layers/streetLevel/providers/kartaview/index.js index a056771dc..b7eb0f567 100644 --- a/src/layers/streetLevel/providers/kartaview/index.js +++ b/src/layers/streetLevel/providers/kartaview/index.js @@ -440,8 +440,14 @@ export function createKartaViewProvider({ if (metres <= NEAREST_RADIUS_M) near.push({ photo, metres }); } near.sort((a, b) => a.metres - b.metres); - for (const { photo } of near.slice(0, NEAREST_PROBES)) - if (await showable(photo, { signal })) return photo.id; + // Probed side by side (photo storage is not the API host): the + // nearest one that answers wins. + const candidates = near.slice(0, NEAREST_PROBES); + const answers = await Promise.all( + candidates.map(({ photo }) => showable(photo, { signal })), + ); + const hit = candidates.find((_, i) => answers[i]); + if (hit) return hit.photo.id; if (near.length) throw new Error(ARCHIVED_MESSAGE); return null; }, diff --git a/src/layers/streetLevel/providers/kartaview/policy.js b/src/layers/streetLevel/providers/kartaview/policy.js index d2d75b5e2..699f7d519 100644 --- a/src/layers/streetLevel/providers/kartaview/policy.js +++ b/src/layers/streetLevel/providers/kartaview/policy.js @@ -71,8 +71,8 @@ export const PAGE_TIMEOUT_MS = 30_000; export const IMAGE_TIMEOUT_MS = 15_000; /** Whether a photo file is there (not archived): headers only. */ export const IMAGE_PROBE_TIMEOUT_MS = 8_000; -/** Nearest photos tried before giving up on archived ones. */ -export const NEAREST_PROBES = 4; +/** Nearest photos probed (at once) before giving up on archived ones; ‹ › skip this many. */ +export const NEAREST_PROBES = 6; export const ARCHIVED_MESSAGE = 'KartaView’s photos here are archived and cannot be shown';