2 import UrlSubmitForm from '../components/UrlSubmitForm.svelte';
3 import DetailsLink from '../components/DetailsLink.svelte';
4 import PageLink from '../components/PageLink.svelte';
6 import { zoomLevels } from '../lib/helpers.js';
7 import { map_store, refresh_page } from '../lib/stores.js';
13 function gotoCoordinates(newlat, newlon, newzoom) {
14 let params = new URLSearchParams();
15 params.set('lat', newlat);
16 params.set('lon', newlon);
17 params.set('zoom', newzoom || zoom);
18 refresh_page('reverse', params);
21 map_store.subscribe(map => {
23 map.on('click', (e) => {
24 let coords = e.latlng.wrap();
25 gotoCoordinates(coords.lat.toFixed(5), coords.lng.toFixed(5));
30 // common mistake is to copy&paste latitude and longitude into the 'lat' search box
31 function maybeSplitLatitude(e) {
32 var coords_split = e.target.value.split(',');
33 if (coords_split.length === 2) {
34 document.querySelector('input[name=lat]').value = L.Util.trim(coords_split[0]);
35 document.querySelector('input[name=lon]').value = L.Util.trim(coords_split[1]);
42 <UrlSubmitForm page="reverse">
43 <div class="form-group">
44 <input name="format" type="hidden" value="html">
45 <label for="reverse-lat">lat</label>
46 <input id="reverse-lat"
49 class="form-control form-control-sm"
50 placeholder="latitude"
52 on:change={maybeSplitLatitude} />
54 on:click|preventDefault|stopPropagation={() => gotoCoordinates(lon, lat)}
55 class="btn btn-outline-secondary btn-sm"
56 title="switch lat and lon"><></a>
57 <label for="reverse-lon">lon</label>
58 <input id="reverse-lon"
61 class="form-control form-control-sm"
62 placeholder="longitude"
64 <label for="reverse-zoom">max zoom</label>
65 <select id="reverse-zoom" name="zoom" class="form-control form-control-sm" bind:value={zoom}>
66 <option value="">---</option>
67 {#each zoomLevels() as zoomTitle, i}
68 <option value="{i}">{i} - {zoomTitle}</option>
71 <button type="submit" class="btn btn-primary btn-sm mx-1">
75 <div class="search-type-link">
76 <DetailsLink extra_classes="mr-2">search by id</DetailsLink>
77 <PageLink page="search">forward search</PageLink>