From 94c1f655213a521027506a135d0d1deb6ae61a13 Mon Sep 17 00:00:00 2001 From: Will Freeman Date: Tue, 24 Dec 2024 14:47:18 -0800 Subject: [PATCH] update map on load --- webapp/src/components/LeafletMap.vue | 6 +----- webapp/src/stores/tiles.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/webapp/src/components/LeafletMap.vue b/webapp/src/components/LeafletMap.vue index 2e45b63..7725822 100644 --- a/webapp/src/components/LeafletMap.vue +++ b/webapp/src/components/LeafletMap.vue @@ -63,7 +63,7 @@ function initializeMap() { attribution: '© OpenStreetMap', }).addTo(map); - populateMap(); + emit('update:bounds', map.getBounds()); // XXX: this event populates the map } function renderCurrentLocation() { @@ -194,10 +194,6 @@ function registerEvents() { emit('update:zoom', map.getZoom()); emit('update:bounds', map.getBounds()); }); - - map.on('load', () => { - emit('update:bounds', map.getBounds()); - }); } /** diff --git a/webapp/src/stores/tiles.ts b/webapp/src/stores/tiles.ts index 1941b2c..9110214 100644 --- a/webapp/src/stores/tiles.ts +++ b/webapp/src/stores/tiles.ts @@ -61,8 +61,13 @@ export const useTilesStore = defineStore('tiles', () => { } const fetchVisibleTiles = async (boundingBox: BoundingBox): Promise => { - if (!(tileUrlTemplate && tileSizeDegrees)) { - console.warn('Tile URL template is not set, skipping fetch'); + if (!tileUrlTemplate || !tileSizeDegrees) { + console.debug('Tile URL template or tile size is not set, fetching...'); + await fetchIndex(); + } + + if (!tileUrlTemplate || !tileSizeDegrees) { + console.warn('Tile URL template or tile size is still not set after fetching index'); return; } @@ -89,8 +94,6 @@ export const useTilesStore = defineStore('tiles', () => { const allNodes = computed(() => Object.values(tiles.value).flat()); - onBeforeMount(fetchIndex); - return { fetchVisibleTiles, allNodes,