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 = ""),