Remove precise-map uncertainty circles
This commit is contained in:
parent
e0220a9c89
commit
15ae829fd6
18
kort7/app.js
18
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", () => {
|
||||
|
|
|
|||
|
|
@ -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 }) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue