Update urls

This commit is contained in:
Austen Adler 2023-04-30 22:17:06 -04:00
parent 964ff0a043
commit 24e6cff9d5
2 changed files with 6 additions and 4 deletions

View File

@ -25,11 +25,15 @@ export function createUrlStore(ssrUrl) {
updateHref(); updateHref();
}; };
history.replaceStateNoNotification = function () {
originalReplaceState.apply(this, arguments);
};
window.addEventListener('popstate', updateHref); window.addEventListener('popstate', updateHref);
window.addEventListener('hashchange', updateHref); window.addEventListener('hashchange', updateHref);
return { return {
subscribe: derived(href, ($href) => new URL($href)).subscribe subscribe: derived(href, ($href) => new URL($href)).subscribe,
}; };
} }

View File

@ -76,8 +76,6 @@
coordinateTypes = rustEnumToArray(wasm.call.CoordinateType); coordinateTypes = rustEnumToArray(wasm.call.CoordinateType);
selectedCoordinateType = coordinateTypes[0]; selectedCoordinateType = coordinateTypes[0];
console.log('My url formats: ', urlFormats, wasm.call.CoordinateUrls);
}) })
.then(async () => { .then(async () => {
leaflet = await import('leaflet'); leaflet = await import('leaflet');
@ -150,7 +148,7 @@
coordinateInputValue = addr.allCoordinates[selectedCoordinateType]; coordinateInputValue = addr.allCoordinates[selectedCoordinateType];
} }
history.replaceState(undefined, undefined, `#${addr.address.replaceAll(' ', '-')}`); history.replaceStateNoNotification(undefined, undefined, `#${addr.address.replaceAll(' ', '-')}`);
map.panTo(latlng, 20); map.panTo(latlng, 20);
leaflet.popup().setLatLng(latlng).setContent(`${addr.address}`).openOn(map); leaflet.popup().setLatLng(latlng).setContent(`${addr.address}`).openOn(map);