X-Git-Url: https://git.openstreetmap.org./nominatim-ui.git/blobdiff_plain/f51f2a70794858f9c8fb5d75ecd40fd1e4ec3897..25ee5c11cb0a351f72da6dadeaa95c526f38e756:/src/components/ReverseLink.svelte?ds=sidebyside

diff --git a/src/components/ReverseLink.svelte b/src/components/ReverseLink.svelte
index 5289999..cfea7c1 100644
--- a/src/components/ReverseLink.svelte
+++ b/src/components/ReverseLink.svelte
@@ -1,31 +1,37 @@
 <script>
 import { refresh_page } from '../lib/stores.js';
 
-export let lat;
-export let lon;
+export let lat = null;
+export let lon = null;
 export let zoom = null;
+export let extra_classes = '';
 
-let params = '';
+let params = new URLSearchParams();
+let href = 'reverse.html';
 
 $: {
+  let new_params = new URLSearchParams();
+
   if (lat && lon) {
-    let new_params = '?lat=' + encodeURIComponent(lat);
-    new_params += '&lon=' + encodeURIComponent(lon);
+    new_params.set('lat', lat);
+    new_params.set('lon', lon);
 
     if (zoom) {
-      new_params += '&zoom=' + encodeURIComponent(zoom);
+      new_params.set('zoom', zoom);
     }
-
-    params = new_params;
-  } else {
-    params = '';
   }
+
+  params = new_params;
 }
 
-function handleClick() {
-  window.history.pushState([], '', 'reverse.html' + params);
-  refresh_page();
+$: {
+  let param_str = params.toString();
+  href = 'reverse.html' + (param_str ? '?' : '') + param_str;
 }
 </script>
 
-<a on:click|preventDefault|stopPropagation={handleClick} href="reverse.html{params}"><slot></slot></a>
+<a on:click|preventDefault|stopPropagation={() => refresh_page('reverse', params)}
+    href={href}
+    class={extra_classes}>
+  <slot></slot>
+</a>
