From 127099ce5a6a3f9b91fa67c0ceec7b782d280571 Mon Sep 17 00:00:00 2001 From: Frank Elsinga Date: Fri, 29 Mar 2024 00:05:37 +0100 Subject: [PATCH] removed `previoslyOnInteractiveMap` as unnessesary --- .../components/DetailsInteractiveMap.vue | 24 +++++++------------ webclient/pages/view/[id].vue | 3 +-- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/webclient/components/DetailsInteractiveMap.vue b/webclient/components/DetailsInteractiveMap.vue index 43a001863..76cfc534a 100644 --- a/webclient/components/DetailsInteractiveMap.vue +++ b/webclient/components/DetailsInteractiveMap.vue @@ -18,7 +18,7 @@ const initialLoaded = ref(false); type DetailsResponse = components["schemas"]["DetailsResponse"]; -function loadInteractiveMap(fromUi = false, previoslyOnInteractiveMap = false) { +function loadInteractiveMap(fromUi = false) { if (!webglSupport) return; const doMapUpdate = function () { @@ -37,8 +37,7 @@ function loadInteractiveMap(fromUi = false, previoslyOnInteractiveMap = false) { } marker.value = new Marker({ element: createMarker() }); const coords = props.data.coords; - if (coords !== undefined && map.value !== undefined) - marker.value.setLngLat([coords.lon, coords.lat]).addTo(map.value as Map); + if (map.value !== undefined) marker.value.setLngLat([coords.lon, coords.lat]).addTo(map.value as Map); const overlays = props.data.maps?.overlays; if (overlays) floorControl.value.updateFloors(overlays); @@ -49,19 +48,12 @@ function loadInteractiveMap(fromUi = false, previoslyOnInteractiveMap = false) { room: 18, }; - if (coords !== undefined) { - if (previoslyOnInteractiveMap) { - map.value?.flyTo({ - center: [coords.lon, coords.lat], - zoom: defaultZooms[props.data.type || "undefined"] || 16, - speed: 1, - maxDuration: 2000, - }); - } else { - map.value?.setZoom(16); - map.value?.setCenter([coords.lon, coords.lat]); - } - } + map.value?.flyTo({ + center: [coords.lon, coords.lat], + zoom: defaultZooms[props.data.type || "undefined"] || 16, + speed: 1, + maxDuration: 2000, + }); }; // The map element should be visible when initializing diff --git a/webclient/pages/view/[id].vue b/webclient/pages/view/[id].vue index ca145f6c7..b27ba1993 100644 --- a/webclient/pages/view/[id].vue +++ b/webclient/pages/view/[id].vue @@ -88,8 +88,7 @@ function tryToLoadMap() { * @return {boolean} Whether the loading was successful */ if (document.getElementById("interactive-map") !== null) { - const previoslyOnInteractiveMap = false - if ( === "interactive") interactiveMap.value?.loadInteractiveMap(false,previoslyOnInteractiveMap); + if (selectedMap.value === "interactive") interactiveMap.value?.loadInteractiveMap(false); // scrolling to the top after navigation window.scrollTo({ top: 0, behavior: "auto" }); return true;