2 import { onMount, onDestroy } from 'svelte';
4 import { page, results_store } from '../lib/stores.js';
5 import { get_config_value } from '../lib/config_reader.js';
6 import { fetch_from_api, update_html_title } from '../lib/api_utils.js';
8 import ReverseBar from '../components/ReverseBar.svelte';
9 import ResultsList from '../components/ResultsList.svelte';
10 import Map from '../components/Map.svelte';
12 let api_request_params;
14 let position_marker; // what the user searched for
17 let search_params = new URLSearchParams(window.location.search);
21 api_request_params = {
22 lat: search_params.get('lat'),
23 lon: search_params.get('lon'),
24 zoom: (search_params.get('zoom') > 1
25 ? Number(search_params.get('zoom'))
26 : Number(get_config_value('Reverse_Default_Search_Zoom'))),
30 if (api_request_params.lat || api_request_params.lat) {
32 fetch_from_api('reverse', api_request_params, function (data) {
33 if (data && !data.error) {
34 position_marker = [api_request_params.lat, api_request_params.lon];
35 results_store.set([data]);
37 results_store.set([]);
40 update_html_title('Reverse result for '
41 + api_request_params.lat
43 + api_request_params.lon);
44 document.querySelector('input[name=lat]').focus();
49 let page_subscription;
50 onMount(() => { page_subscription = page.subscribe(loaddata); });
51 onDestroy(() => { page_subscription(); });
54 <ReverseBar api_request_params={api_request_params} />
58 <ResultsList bind:current_result reverse_search={true} />
60 <div id="map-wrapper">
61 <Map {current_result} {position_marker} display_minimap={true} />
71 display: inline-block;
78 height: calc(100vh - 250pt);
81 display: inline-block;
85 @media (max-width: 768px) {