From 3ddc526cf83e009705cb4d34ffba9b12c5d6b36d Mon Sep 17 00:00:00 2001 From: Mikkel Date: Tue, 7 Feb 2023 14:56:38 +0100 Subject: [PATCH] don't know what i did --- frontend/src/main.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/src/main.ts b/frontend/src/main.ts index 9f77e2c..6c9e492 100644 --- a/frontend/src/main.ts +++ b/frontend/src/main.ts @@ -88,6 +88,23 @@ function setupMap( }); }; + mapImg.onmouseup = async (event: MouseEvent) => { + const mousePosition: Position = { x: event.offsetX, y: event.offsetY }; + displayMousePosition(mousePositionElement, mousePosition); + const mapSize: Size = { + width: mapImg.clientWidth, + height: mapImg.clientHeight, + }; + const coords = convertPixelsToCoordinate(mousePosition, mapSize); + displayCoords(coordsElement, coords); + fetcher.call(async () => { + const response = await fetchZipCode(coords); + displayZipCode(zipCodeElement, response.nr, response.navn); + console.log("test") + }); + + } + mapImg.onmouseleave = (_event: MouseEvent) => { [mousePositionElement, coordsElement, zipCodeElement].forEach( (e) => (e.innerHTML = ""),