2 import UrlSubmitForm from '../components/UrlSubmitForm.svelte';
4 import { zoomLevels } from '../lib/helpers.js';
5 import { map_store, refresh_page } from '../lib/stores.js';
11 function gotoCoordinates(newlat, newlon, newzoom) {
12 let params = new URLSearchParams();
13 params.set('lat', newlat);
14 params.set('lon', newlon);
15 params.set('zoom', newzoom || zoom);
16 refresh_page('reverse', params);
19 map_store.subscribe(map => {
21 map.on('click', (e) => {
22 let coords = e.latlng.wrap();
23 gotoCoordinates(coords.lat.toFixed(5), coords.lng.toFixed(5));
28 // common mistake is to copy&paste latitude and longitude into the 'lat' search box
29 function maybeSplitLatitude(e) {
30 var coords_split = e.target.value.split(',');
31 if (coords_split.length === 2) {
32 document.querySelector('input[name=lat]').value = L.Util.trim(coords_split[0]);
33 document.querySelector('input[name=lon]').value = L.Util.trim(coords_split[1]);
39 <UrlSubmitForm page="reverse">
40 <div class="form-group">
41 <label for="reverse-lat">lat</label>
42 <input id="reverse-lat"
45 class="form-control form-control-sm"
46 placeholder="latitude"
48 on:change={maybeSplitLatitude} />
50 <div class="form-group">
52 on:click|preventDefault|stopPropagation={() => gotoCoordinates(lon, lat)}
53 class="btn btn-outline-secondary btn-sm"
54 title="switch lat and lon"><></a>
56 <div class="form-group">
57 <label for="reverse-lon">lon</label>
58 <input id="reverse-lon"
61 class="form-control form-control-sm"
62 placeholder="longitude"
65 <div class="form-group">
66 <label for="reverse-zoom">max zoom</label>
67 <select id="reverse-zoom" name="zoom" class="form-control form-control-sm" bind:value={zoom}>
68 <option value="">---</option>
69 {#each zoomLevels() as zoomTitle, i}
70 <option value="{i}">{i} - {zoomTitle}</option>
74 <div class="form-group">
75 <button type="submit" class="btn btn-primary btn-sm mx-1">Search</button>
94 @media (max-width: 850px) {
95 #reverse-lon, #reverse-lat, #reverse-zoom {