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 <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"
49 on:change={maybeSplitLatitude} />
51 on:click|preventDefault|stopPropagation={() => gotoCoordinates(lon, lat)}
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"
61 <label for="reverse-zoom">max zoom</label>
62 <select id="reverse-zoom" name="zoom" class="form-control form-control-sm" bind:value={zoom}>
63 <option value="">---</option>
64 {#each zoomLevels() as zoomTitle, i}
65 <option value="{i}">{i} - {zoomTitle}</option>
68 <button type="submit" class="btn btn-primary btn-sm mx-1">