diff --git a/kort7/app.js b/kort7/app.js index 5aa77bc..9fde0d6 100644 --- a/kort7/app.js +++ b/kort7/app.js @@ -211,6 +211,7 @@ function getPresenceState(view, lat, lon, uncertaintyM) { } function ensureUncertaintyCircle(view, v) { + if (view.positionKey === "true") return; if (v.uncertaintyCircle || v.current.uncertaintyM <= 0) return; v.uncertaintyCircle = L.circle([v.displayLat, v.displayLon], { radius: v.current.uncertaintyM, @@ -225,6 +226,12 @@ function ensureUncertaintyCircle(view, v) { } function syncUncertaintyCircle(view, v) { + if (view.positionKey === "true") { + if (v.uncertaintyCircle && view.map.hasLayer(v.uncertaintyCircle)) { + view.map.removeLayer(v.uncertaintyCircle); + } + return; + } if (v.current.uncertaintyM > 0) ensureUncertaintyCircle(view, v); if (!v.uncertaintyCircle) return; if (v.current.uncertaintyM <= 0) { @@ -467,8 +474,7 @@ function invalidateAllMaps() { } for (const view of views) { - view.indicatorsEl.addEventListener("click", (event) => { - const button = event.target.closest(".offmap-indicator"); + function handleIndicatorSelection(button) { if (!button) return; const v = view.vehicles[button.dataset.vehicle]; setActiveIndicator(view, v.name); @@ -478,6 +484,14 @@ for (const view of views) { source: "hjørneindikator", state: v }); + } + + view.indicatorsEl.addEventListener("click", (event) => { + handleIndicatorSelection(event.target.closest(".offmap-indicator")); + }); + + view.indicatorsEl.addEventListener("pointerup", (event) => { + handleIndicatorSelection(event.target.closest(".offmap-indicator")); }); view.map.on("moveend zoomend", () => { diff --git a/kort7/tests/kort7.spec.js b/kort7/tests/kort7.spec.js index 049af8d..265acde 100644 --- a/kort7/tests/kort7.spec.js +++ b/kort7/tests/kort7.spec.js @@ -40,18 +40,27 @@ test.describe('kort7 dual map demo', () => { await expect(indicator).toHaveClass(/active/); }); - test('renders uncertainty circles on the maps', async ({ page }) => { + test('renders uncertainty circles only on approximate map', async ({ page }) => { await page.goto('/kort7.html'); await waitForMaps(page); await expect.poll(async () => { - return await page.locator('path').evaluateAll((nodes) => + return await page.locator('#mapApprox path').evaluateAll((nodes) => nodes.filter((node) => { const strokeDasharray = node.getAttribute('stroke-dasharray'); return strokeDasharray && strokeDasharray.length > 0; }).length ); }).toBeGreaterThan(0); + + await expect.poll(async () => { + return await page.locator('#mapTrue path').evaluateAll((nodes) => + nodes.filter((node) => { + const strokeDasharray = node.getAttribute('stroke-dasharray'); + return strokeDasharray && strokeDasharray.length > 0; + }).length + ); + }).toBe(0); }); test('shows off-map indicators on both views', async ({ page }) => {