]> git.openstreetmap.org Git - nominatim-ui.git/commitdiff
split latitude value if copy&pasted as pair (#62)
authormtmail <mtmail@gmx.net>
Wed, 10 Feb 2021 14:04:19 +0000 (15:04 +0100)
committerGitHub <noreply@github.com>
Wed, 10 Feb 2021 14:04:19 +0000 (15:04 +0100)
src/components/ReverseBar.svelte

index a045a82f2a8d41953e52e00ffdb5aff57cd37515..c7f081dd3428e77c8dc18574871deed908af0479 100644 (file)
     document.querySelector('input[name=lon]').value = lat;
     document.querySelector('form').submit();
   }
+
+  // common mistake is to copy&paste latitude and longitude into the 'lat' search box
+  function maybeSplitLatitude(e) {
+    var coords_split = e.target.value.split(',');
+    if (coords_split.length === 2) {
+      document.querySelector('input[name=lat]').value = L.Util.trim(coords_split[0]);
+      document.querySelector('input[name=lon]').value = L.Util.trim(coords_split[1]);
+    }
+  }
+
 </script>
 
 <div class="top-bar">
@@ -35,7 +45,8 @@
              type="text"
              class="form-control form-control-sm"
              placeholder="latitude"
-             value="{api_request_params.lat || ''}" />
+             value="{api_request_params.lat || ''}"
+             on:change={maybeSplitLatitude} />
       <a id="switch-coords"
          on:click|preventDefault|stopPropagation={handleSwitchCoords}
          class="btn btn-outline-secondary btn-sm"