Skip to content

Commit

Permalink
feat: default to flyTo when setting map center
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Oct 8, 2024
1 parent 7eb640c commit ce33080
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion web/src/components/map/Map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default {

onMounted(() => {
createMap();
setMapCenter();
setMapCenter(undefined, true);
});

return {
Expand Down
12 changes: 10 additions & 2 deletions web/src/storeFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit ce33080

Please sign in to comment.