From ce3308061dbaec28c955cea79d996319c95579f6 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Tue, 8 Oct 2024 22:01:28 +0000 Subject: [PATCH] feat: default to `flyTo` when setting map center --- web/src/components/map/Map.vue | 2 +- web/src/storeFunctions.ts | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/src/components/map/Map.vue b/web/src/components/map/Map.vue index b6069f3c..c7e5ca65 100644 --- a/web/src/components/map/Map.vue +++ b/web/src/components/map/Map.vue @@ -152,7 +152,7 @@ export default { onMounted(() => { createMap(); - setMapCenter(); + setMapCenter(undefined, true); }); return { diff --git a/web/src/storeFunctions.ts b/web/src/storeFunctions.ts index 087c0cc0..a196ee9d 100644 --- a/web/src/storeFunctions.ts +++ b/web/src/storeFunctions.ts @@ -87,15 +87,23 @@ export function loadProjects() { }); } -export function setMapCenter(project: Project | undefined = undefined) { +export function setMapCenter( + project: Project | undefined = undefined, + jump = false +) { let center: [number, number] = [0, 30]; let zoom = 1; if (project) { center = project.default_map_center; zoom = project.default_map_zoom; } + const map = getMap(); - map.jumpTo({ center, zoom }); + if (jump) { + map.jumpTo({ center, zoom }); + } else { + map.flyTo({ center, zoom, duration: 2000 }); + } } export function getCurrentMapPosition() {