From 0576fc4187fba948714c964ea9881039a0de481e Mon Sep 17 00:00:00 2001 From: Trent Larson <trent@trentlarson.com> Date: Tue, 21 Jan 2025 19:51:58 -0700 Subject: [PATCH] fix a jump on user profile map move & recenter --- src/router/index.ts | 4 +--- src/views/AccountViewView.vue | 11 ++++++++--- src/views/DiscoverView.vue | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/router/index.ts b/src/router/index.ts index 3f9a3ff64..b8b1be70c 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -279,9 +279,7 @@ const errorHandler = ( ) => { // Handle the error here console.error("Caught in top level error handler:", error, to, from); - alert( - "Something is very wrong. We'd love if you contacted us and let us know how you got here. Thank you!", - ); + alert("Something is very wrong. Try reloading or restarting the app."); // You can also perform additional actions, such as displaying an error message or redirecting the user to a specific page }; diff --git a/src/views/AccountViewView.vue b/src/views/AccountViewView.vue index e5864e6f4..5145870bc 100644 --- a/src/views/AccountViewView.vue +++ b/src/views/AccountViewView.vue @@ -302,9 +302,7 @@ </p> <l-map - ref="map" - v-model:zoom="zoom" - :center="[userProfileLatitude, userProfileLongitude]" + ref="profileMap" class="!z-40 rounded-md" @click=" (event: LeafletMouseEvent) => { @@ -312,6 +310,7 @@ userProfileLongitude = event.latlng.lng; } " + @ready="onMapReady" > <l-tile-layer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" @@ -1797,6 +1796,12 @@ export default class AccountViewView extends Vue { } } + onMapReady(map: L.Map) { + // doing this here instead of on the l-map element avoids a recentering after a drag then zoom at startup + const zoom = this.userProfileLatitude && this.userProfileLongitude ? 12 : 2; + map.setView([this.userProfileLatitude, this.userProfileLongitude], zoom); + } + showProfileInfo() { this.$notify( { diff --git a/src/views/DiscoverView.vue b/src/views/DiscoverView.vue index d3d1f2198..db43e71c8 100644 --- a/src/views/DiscoverView.vue +++ b/src/views/DiscoverView.vue @@ -619,7 +619,7 @@ export default class DiscoverView extends Vue { } async onMapReady(map: L.Map) { - // doing this here instead of the l-map element avoids a recentering after the first drag + // doing this here instead of on the l-map element avoids a recentering after a drag then zoom at startup map.setView([this.localCenterLat, this.localCenterLong], 2); this.requestTiles(map); }