dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
283 stars 34 forks source link

Warning when using history.replaceState with SvelteKit #174

Closed ragone closed 1 month ago

ragone commented 1 month ago

When using hash = true together with SvelteKit, the following warning appears in the console.

Avoid using `history.pushState(...)` and `history.replaceState(...)` as these will conflict with SvelteKit's router. Use the `pushState` and `replaceState` imports from `$app/navigation` instead.

Would it be possible to let the user choose how to update the history?

dimfeld commented 1 month ago

Yeah these could probably be passed as props and then it can use them instead of the browser built in. I’m about to have a baby so not sure when I’ll have time to do this, but I agree it’s a good idea :)

dabreegster commented 1 month ago

+1

Also mentioning that I think I messed up in #142. If you're using the hash feature and update the URL, the viewport doesn't always correctly update when both zoom and offset change. I'll try and fix this soon, just an FYI if you're testing things and see unexpected behavior there

(Congratulations about your soon-to-be newborn!)

dimfeld commented 1 month ago

+1

Also mentioning that I think I messed up in #142. If you're using the hash feature and update the URL, the viewport doesn't always correctly update when both zoom and offset change. I'll try and fix this soon, just an FYI if you're testing things and see unexpected behavior there

(Congratulations about your soon-to-be newborn!)

Thanks! That actually sounds like a more general bug, which might be fixed by https://github.com/dimfeld/svelte-maplibre/pull/169

dabreegster commented 1 month ago

Thanks! That actually sounds like a more general bug, which might be fixed by https://github.com/dimfeld/svelte-maplibre/pull/169

Indeed, everything seems correct after updating. Thanks for fixing this!