2 import UrlSubmitForm from '../components/UrlSubmitForm.svelte';
4 import { zoomLevels } from '../lib/helpers.js';
5 import { map_store } from '../lib/stores.js';
7 export let api_request_params = {};
9 map_store.subscribe(map => {
12 map.on('click', function (e) {
13 document.querySelector('input[name=lat]').value = e.latlng.lat.toFixed(5);
14 document.querySelector('input[name=lon]').value = e.latlng.wrap().lng.toFixed(5);
15 document.querySelector('form').submit();
19 function handleSwitchCoords() {
20 let lat = document.querySelector('input[name=lat]').value;
21 let lon = document.querySelector('input[name=lon]').value;
22 document.querySelector('input[name=lat]').value = lon;
23 document.querySelector('input[name=lon]').value = lat;
24 document.querySelector('form').submit();
27 // common mistake is to copy&paste latitude and longitude into the 'lat' search box
28 function maybeSplitLatitude(e) {
29 var coords_split = e.target.value.split(',');
30 if (coords_split.length === 2) {
31 document.querySelector('input[name=lat]').value = L.Util.trim(coords_split[0]);
32 document.querySelector('input[name=lon]').value = L.Util.trim(coords_split[1]);
40 <div class="form-group">
41 <input name="format" type="hidden" value="html">
42 <label for="reverse-lat">lat</label>
43 <input id="reverse-lat"
46 class="form-control form-control-sm"
47 placeholder="latitude"
48 value="{api_request_params.lat || ''}"
49 on:change={maybeSplitLatitude} />
51 on:click|preventDefault|stopPropagation={handleSwitchCoords}
52 class="btn btn-outline-secondary btn-sm"
53 title="switch lat and lon"><></a>
54 <label for="reverse-lon">lon</label>
55 <input id="reverse-lon"
58 class="form-control form-control-sm"
59 placeholder="longitude"
60 value="{api_request_params.lon || ''}" />
61 <label for="reverse-zoom">max zoom</label>
62 <select id="reverse-zoom" name="zoom" class="form-control form-control-sm" value="{api_request_params.zoom}">
63 <option value="" selected={!api_request_params.zoom}>---</option>
64 {#each zoomLevels() as zoomTitle, i}
65 <option value="{i}" selected={i === api_request_params.zoom}>{i} - {zoomTitle}</option>
68 <button type="submit" class="btn btn-primary btn-sm mx-1">
72 <div class="search-type-link">
73 <a href="details.html" class="mr-2">search by id</a>
74 <a href="search.html">forward search</a>